The Framework Code

class/framework/model/rolecontext.php

File List

<?php
/**
 * A model class for the RedBean object RoleContext
 *
 * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! This is a Framework system class - do not edit !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
 *
 * @author Lindsay Marshall <lindsay.marshall@ncl.ac.uk>
 * @copyright 2018-2021 Newcastle University
 * @package Framework\Model
 */
    namespace Framework\Model;

    use \Config\Framework as FW;
    use \Support\Context;
/**
 * A class implementing a RedBean model for RoleContext beans
 * @psalm-suppress UnusedClass
 */
    final class RoleContext extends \RedBeanPHP\SimpleModel
    {
/**
 * Function called when a rolecontext bean is updated - do error checking in here
 *
 * @throws \Framework\Exception\BadValue
 */
        public function update() : void
        {
            if (!\preg_match('/^[a-z][a-z0-9]*/i', $this->bean->name))
            {
                throw new \Framework\Exception\BadValue('Invalid context name');
            }
        }
/**
 * Add a RoleContext from a form - invoked by the AJAX bean operation
 *
 * @see \Framework\Ajax\Bean
 */
        public static function add(Context $context) : \RedBeanPHP\OODBBean
        {
            $p = \R::dispense(FW::ROLECONTEXT);
            $p->name = $context->formdata('post')->mustFetch('name');
            $p->fixed = 0;
            \R::store($p);
            return $p;
        }
    }
?>