Run all operations that have to occur before actually
storing the entity.

@throws \InvalidArgumentException

@return void
498746
protected function preStoreProcess()
    {
        // Create any related object that doesn't exist in the database.
        $localRelationships = $this->aggregate->getEntityMap()->getLocalRelationships();

        $this->createRelatedEntities($localRelationships);

        // Now we can sync the related collections
        $this->aggregate->syncRelationships($localRelationships);
    }
1000684
public function run(): void
    {
        // dynamicly parse input params
        $args = func_get_args();
        
        if (count($args) < 1) {
            return;
        }
        
        // get event name
        $eventName = array_shift($args);
        // get event args as array if passed
        $eventArgs = @array_shift($args);

        // if event is registered
        if (isset($this->events[$eventName]) && Any::isArray($this->events[$eventName])) {
            foreach ($this->events[$eventName] as $callback) {
                // call anonymous function with args if passed
                call_user_func_array($callback, $eventArgs);
            }
        }
        
        // set to post runned actions
        $this->runned[$eventName] = $eventArgs;
    }
1311578
private function buildRegistries()
    {
        if (is_object($this->entity) && $this->isRegistryEntity($this->entity)) {
            $this->buildRegistryFromObject();
        } else {
            throw new \InvalidArgumentException(sprintf(
                'Cannot build registries: current entity must be an instance of %s, current `%s`.',
                'BackBee\Bundle\Registry\RegistryEntityInterface',
                gettype($this->entity)
            ));
        }

        foreach ($this->registries as $registry) {
            $this->entity->{$registry->getKey()} = $registry->getValue();
        }
    }
402732
protected function initInstances()
    {
        if (empty($this->instances)) {
            foreach ($this->servers as $server) {
                if ($server instanceof \Redis) {
                    if ($server->isConnected()) {
                        $redis = $server;
                    } else {
                        throw new \InvalidArgumentException("If you use \\Redis objects as argument, the object must be connected.");
                    }
                } else {
                    if (empty($server[0])) {
                        throw new \InvalidArgumentException("A server hostname or IP is required");
                    }

                    if (empty($server[1])) {
                        $server[1] = 6379;
                    }
                    if (empty($server[2])) {
                        $server[2] = 0;
                    }
                    list($host, $port, $timeout) = $server;
                    $redis = new \Redis();
                    $redis->connect($host, $port, $timeout);
                }
                $this->instances[] = $redis;
            }
        }
    }
271678
public function run()
    {
        if (is_callable($this->closure)) {
            // Set the error handler for the spec
            set_error_handler([$this, 'handleError'], E_ALL);

            // Invoke the closure while catching exceptions
            try {
                $this->closure->__invoke();
            } catch (ExpectationException $exception) {
                $this->exception = $exception;
            } catch (\Exception $exception) {
                $this->handleException($exception);
            }

            restore_error_handler();
        }
    }
192847
public function run()
    {
        $table = $this->table(CMS_TABLE_USERS);
        $table->insert($this->records)->save();
    }
486445
public function run() {
		$array = ValueUtils::val($this->array);
		foreach ($array as $key => $value) {
			if ($this->key != null) {
				$this->key->setValue($key);
			}
			if ($this->value != null) {
				$this->value->setValue($value);
			}
			foreach ($this->actions as $action) {
				$action->run();
			}
		}
	}
539257
protected function runSoftDelete()
    {
        $query = $this->newQuery()->where($this->getKeyName(), $this->getKey());

        $this->setAttribute($column = $this->getDeletedAtColumn(), $time = $this->freshTimestamp());

        $query->update(array($column => $this->fromDateTime($time)));
    }
1195817
protected function execute() {
        $this->log('creating the stash storage', backup::LOG_DEBUG);
        $this->create_stash_storage();

        $this->log('parsing moodle.xml starts', backup::LOG_DEBUG);
        $this->xmlparser->process();
        $this->log('parsing moodle.xml done', backup::LOG_DEBUG);

        $this->log('dropping the stash storage', backup::LOG_DEBUG);
        $this->drop_stash_storage();
    }
191543
public function initialize()
    {
        $this->initializeShortAliases();
        $this->initializeDefaultAliases();
        foreach ($this->schemaManager->getSchemaTables() as $table) {
            $this->loadMetadataForTable($table);
        }
        $this->initialized = true;
    }
995979
protected function beforeCreate()
    {
        $this->dispatcher->getEventsManager()->fire(Events::BEFORE_CREATE, $this);
        $this->beforeSave();
    }
1243947
public function run()
    {
        $vendorDir = dirname(dirname(__FILE__));
        $baseDir = dirname($vendorDir);
        spl_autoload_register(function ($className) use($baseDir) {
            if (file_exists($file = $baseDir . '/database/seeds/' . $className . '.php')) {
                include($file);
                return true;
            }
        });

        $this->call([
            ModulesTableSeeder::class,
            PrivilegesTableSeeder::class,
            SettingsTableSeeder::class,
        ]);
    }
1374035
public function run()
    {
        foreach (['super', 'admin', 'banned', 'author', 'registered'] as $role) {
            if (DB::table('roles')->where(compact('role'))->first()) {
                continue;
            }

            DB::table('roles')->insert(compact('role'));
        }
    }
543029
public function execute()
    {
        $entity = $this->aggregate->getEntityObject();
        $wrappedEntity = $this->aggregate->getWrappedEntity();
        $mapper = $this->aggregate->getMapper();

        if ($mapper->fireEvent('storing', $wrappedEntity) === false) {
            return false;
        }

        $this->preStoreProcess();

        /*
         * We will test the entity for existence
         * and run a creation if it doesn't exists
         */
        if (!$this->aggregate->exists()) {
            if ($mapper->fireEvent('creating', $wrappedEntity) === false) {
                return false;
            }

            $this->insert();

            $mapper->fireEvent('created', $wrappedEntity, false);
        } elseif ($this->aggregate->isDirty()) {
            if ($mapper->fireEvent('updating', $wrappedEntity) === false) {
                return false;
            }
            $this->update();

            $mapper->fireEvent('updated', $wrappedEntity, false);
        }

        $this->postStoreProcess();

        $mapper->fireEvent('stored', $wrappedEntity, false);

        // Once the object is stored, add it to the Instance cache
        $key = $this->aggregate->getEntityKeyValue();

        if (!$mapper->getInstanceCache()->has($key)) {
            $mapper->getInstanceCache()->add($entity, $key);
        }

        $this->syncForeignKeyAttributes();

        $wrappedEntity->unwrap();

        return $entity;
    }
80371
public function run()
    {
        config()->set('gzero-core.db_transactions', false);
        $languages = Language::all()->keyBy('code');
        $users     = $this->seedUsers();
        $contents  = $this->seedContent($languages, $users);
        $this->seedBlock(BlockType::all(), $languages, $users, $contents);
        //$fileTypes    = $this->seedFileTypes();
        //$files        = $this->seedFiles($fileTypes, $languages, $users, $contents, $blocks);
        //$this->seedOptions($languages);
    }
585991
protected function runApplicationWithEvents()
    {
        $this->prepareEnvironment();

        if (static::$before) {
            $this->runBeforeCallbacks();
        }
        // read configs/general.php for register aliases
        $this->readGeneralConfigs();
        // register all aliases
        $this->registerAliases();
        // register helpers;
        $this->resolveHelpers();

        //execute the service providers
        $this->prepareServiceProviders();

        if (static::$after) {
            $this->runAfterCallbacks();
        }
    }
307268
public function preRun(){

        if(!isset($this->parameters['target']) ){
            $this->parameters['target'] = $this->parameters['t']; 
        }

        if(!isset($this->parameters['documentRoot']) ){
            $this->parameters['documentRoot'] = $this->parameters['d'];
        }
        if(!isset($this->parameters['serverName']) ){
            $this->parameters['serverName'] = $this->parameters['s'];
        }
        if(!isset($this->parameters['tpl']) ){
            $this->parameters['tpl'] = dirname(__FILE__). '/sample/sample.conf';
        }
        
        $fileinfo =pathinfo($this->parameters['target']);
        
        if($fileinfo['extension'] != 'conf'){
            $this->err('Extension of target file has to be conf', true);
        }
    }