Actualiza registro del modelo filtrando con llaves.

@throws \RuntimeException
516006
public function actualizar()
    {
        // Preparamos variables a usar
        $filtro = [];
        $parametros = [];
        $llavePrimaria = (array) $this->__llavePrimaria;

        // Hacemos recorrido de campos para rellenar parametros de actualización
        foreach ($this->__campos as $campo => $meta) {
            // Validamos si el campo cumple con su requerimiento
            if (!empty($meta['requerido']) && $this->campoVacio($campo)) {
                throw new \RuntimeException("Falta el campo requerido '{$campo}'.");
            }

            // Agregamos campo a los parametros de inserción
            if (isset($this->{$campo})) {
                $parametros[$campo . '|' . $meta['tipo']] = $this->{$campo};
            }
        }

        // Hacemos recorrido de llave primaria para rellenar el filtro de consulta
        foreach ($llavePrimaria as $campo) {
            if ($this->campoVacio($campo)) {
                throw new \RuntimeException("Falta rellenar el campo llave '{$campo}'.");
            }

            $filtro[$campo . '|' . $this->__campos[$campo]['tipo']] = $this->{$campo};
        }

        return Aplicacion::instanciar()->obtenerBdRelacional()
            ->actualizar($this->__nombreTabla, $parametros)
            ->donde($filtro)
            ->ejecutar();
    }
97386
public function init()
    {
        if (!$this->getQuery()) {
            throw new \RuntimeException('Uninitialized QueryBuilder');
        }

        $this->resetIterator();
        $this->setNbResults($this->computeNbResult());

        if (0 == $this->getPage() || 0 == $this->getMaxPerPage() || 0 == $this->getNbResults()) {
            $this->setLastPage(0);
            $this->getQuery()->setFirstResult(0);
            $this->getQuery()->setMaxResults(0);
        } else {
            $offset = ($this->getPage() - 1) * $this->getMaxPerPage();
            $this->setLastPage(ceil($this->getNbResults() / $this->getMaxPerPage()));
            $this->getQuery()->setFirstResult($offset);
            $this->getQuery()->setMaxResults($this->getMaxPerPage());
        }
    }
1243661
protected function init()
	{
		if (isset($this->template) === false)
		{
			throw new \RuntimeException('Template property does not exist.');
		}

		if (empty($this->template) === false and is_string($this->template))
		{
			$this->template = $this->view($this->template);
		}
	}
350776
public function init()
    {
        $stream = @fopen($this->config['url'], 'a');
        if (!$stream) {
            throw new \RuntimeException(sprintf("Couldn't open resource '%s'", $this->config['url']));
        }

        $this->stream = $stream;

        if (!empty($this->config['lock']) && $this->config['lock'] === true && stream_supports_lock($this->stream)) {
            $this->useLocks = true;
        }
    }
1286645
public function create()
    {
        if ($this->getIsNewRecord() == false) {
            throw new \RuntimeException('Calling "' . __CLASS__ . '::' . __METHOD__ . '" on existing user');
        }

        $transaction = $this->getDb()->beginTransaction();

        try {
            $this->password = ($this->password == null && $this->module->enableGeneratingPassword) ? Password::generate(8) : $this->password;

            $this->trigger(self::BEFORE_CREATE);

            if (!$this->save()) {
                $transaction->rollBack();
                return false;
            }

            $this->confirm();

            $this->mailer->sendWelcomeMessage($this, null, true);
            $this->trigger(self::AFTER_CREATE);

            $transaction->commit();

            return true;
        } catch (\Exception $e) {
            $transaction->rollBack();
            \Yii::warning($e->getMessage());
            throw $e;
        }
    }
216849
protected function _get_stored_data()
    {
        if (!($prim_key = static::table()->primaryKey()) && !$this->storedAttributes) {
            throw new Exception\RuntimeException(
                "Can't find data without primary key nor storedAttributes"
            );
        }
        
        $query = static::none();
        
        if ($prim_key) {
            $query->where('`'.$prim_key.'` = ?', $this->$prim_key);
        } else {
            $model = new static();
            $cols_names = static::table()->columnNames();
            foreach ($this->storedAttributes as $name => $value) {
                if (in_array($name, $cols_names)) {
                    $model->attributes[$name] = $value;
                }
            }
            
            if (!$model->attributes)
                throw new Exception\RuntimeException(
                    "Model rebuilt from storedAttributes failed"
                );
            else
                return $model;
        }
        
        $current = $query->first();
        
        if (!$current)
            throw new Exception\RuntimeException(
                "Row not found in database (searched with storedAttributes)"
            );
        else
            return $current;
    }
586194
protected function structureModelFactory()
    {
        if (!isset($this->structureModelFactory)) {
            throw new RuntimeException(sprintf(
                'Model Factory is not defined for "%s"',
                get_class($this)
            ));
        }

        return $this->structureModelFactory;
    }
600982
public function execute()
    {
        foreach (array_unique($this->bootstrappers->all()) as $class) {
            $bootstrapper = $this->create($class);

            if (!method_exists($bootstrapper, 'run')) {
                throw new \RuntimeException("$class must have run() method");
            }

            $bootstrapper->run();
        }
    }
1090130
public function filter($value)
    {
        if (!is_scalar($value) && !is_array($value)) {
            return $value;
        }

        if ($this->options['pattern'] === null) {
            throw new Exception\RuntimeException(sprintf(
                'Filter %s does not have a valid pattern set',
                get_class($this)
            ));
        }

        return preg_replace($this->options['pattern'], $this->options['replacement'], $value);
    }
1311378
protected function validateFilePath()
    {
        if (file_exists($this->filePath)) {
            if (!is_writable($this->filePath)) {
                throw new RuntimeException(
                    "File '{$this->filePath}' exist but is not writable"
                );
            }
        } else {
            if (!is_writable(dirname($this->filePath))) {
                throw new RuntimeException(
                    "File '{$this->filePath}' is not writable"
                );
            }
        }
    }
169295
public function build()
    {
        if (is_null($this->selectFields) || is_null($this->fromReportType)) {
            throw new RuntimeException('The `select()` and `from()` functions' .
                ' must be called prior to this function');
        }

        $awql = $this->buildSelectClause();
        $awql = $this->appendFromClause($awql);
        $awql = $this->appendWhereClause($awql);
        $awql = $this->appendDuringClause($awql);

        return new ReportQuery(
            $awql
        );
    }
1092614
public function process()
    {
        $this->_cleanFilesStack();
        $this->init();

        if (empty($this->destination_file) && false===$this->direct_output) {
            $this->guessDestinationFilename();
        }

        if (!method_exists($this->__adapter, $this->__adapter_action)) {
            throw new \RuntimeException(
                sprintf('[Compressor] Action "%s" doesn\'t exist in "%s" adapter!', $this->__adapter_action, get_class($this->__adapter))
            );
        }

        if (false===$this->direct_output) {
            if (!$this->mustRefresh()) {
                $this->output = file_get_contents($this->getDestinationRealPath());
                return $this;
            }
        }

        $this->prepare();
        $stack = $this->getContents();
        $contents = array();
        foreach ($stack as $_name=>$_content) {
            $contents[] = '';
            $contents[] = $this->__adapter->buildComment($_name);
            $contents[] = $this->__adapter->{$this->__adapter_action}($_content);
        }
        if (!empty($this->raw_header)) {
            $this->output = $this->raw_header."\n";
        }
        $this->output .= implode("\n", $contents);

        if (!empty($this->output) && false===$this->direct_output) {
            $this->_writeDestinationFile();
        }
        return strlen($this->output);
    }
776067
public function execute()
    {
        $statement = $this->getPdoStatement();
        $result = $statement->execute($this->bindings);
        if (!$result) {
            $errorInfo = $statement->errorInfo();
            throw new RuntimeException(
                $errorInfo[1],
                $errorInfo[2]
            );
        }
        return $statement;
    }
1186789
public static function register()
    {
        if ( self::$hasBeenRegistered === true ) {
            return;
        }

        if ( stream_filter_register(self::getFilterName(), __CLASS__) === false ) {
            throw new RuntimeException('Failed to register stream filter: '.self::getFilterName());
        }

        self::$hasBeenRegistered = true;
    }
764493
public function delete()
    {
        if (is_null($this->primaryKey) ||  is_null($this->getKey())) {
            throw new RuntimeException("No primary key defined on model.");
        }

        if ($this->exists) {
            if ($this->fireModelEvent('deleting') === false) {
                return false;
            }

            if (! $this->performDeleteOnModel()) {
                return false;
            }

            $this->exists = false;

            // Once the model has been deleted, we will fire off the deleted event so that
            // the developers may hook into post-delete operations. We will then return
            // a boolean true which indicated the success of the delete operation on the API.
            $this->fireModelEvent('deleted', true);

            return true;
        }
    }
1133885
public function register()
    {
        if ($this->getIsNewRecord() == false) {
            throw new \RuntimeException('Calling "' . __CLASS__ . '::' . __METHOD__ . '" on existing user');
        }

        $module = UsersModule::module();

        if (empty($this->password) === true) {
            $this->password = PasswordHelper::generate($module->generatedPasswordLength);
        }

        if ($module->emailConfirmationNeeded === false) {
            $this->is_active = true;
        }

        $event = new RegistrationEvent();
        $this->trigger(self::EVENT_BEFORE_REGISTER, $event);

        if ($event->isValid === false) {
            return false;
        }

        if (!$this->save()) {
            return false;
        }

        $this->trigger(self::EVENT_AFTER_REGISTER, $event);
        return $this;
    }
790096
private function config()
    {
        if (realpath($this->configPath) !== false) {
            $json = file_get_contents($this->configPath);
            $this->config = json_decode($json);
            $this->config->rootDir = $this->rootDir;
        } else {
            throw new \RuntimeException('Framework not initialized yet. Consider running composer install');
        }
    }