Ejemplo n.º 1
0
Archivo: Api.php Proyecto: keeko/core
 /**
  * Performs the work of inserting or updating the row in the database.
  *
  * If the object is new, it inserts it; otherwise an update is performed.
  * All related objects are also updated in this method.
  *
  * @param      ConnectionInterface $con
  * @return int             The number of rows affected by this insert/update and any referring fk objects' save() operations.
  * @throws PropelException
  * @see save()
  */
 protected function doSave(ConnectionInterface $con)
 {
     $affectedRows = 0;
     // initialize var to track total num of affected rows
     if (!$this->alreadyInSave) {
         $this->alreadyInSave = true;
         // We call the save method on the following object(s) if they
         // were passed to this object by their corresponding set
         // method.  This object relates to these object(s) by a
         // foreign key reference.
         if ($this->aAction !== null) {
             if ($this->aAction->isModified() || $this->aAction->isNew()) {
                 $affectedRows += $this->aAction->save($con);
             }
             $this->setAction($this->aAction);
         }
         if ($this->isNew() || $this->isModified()) {
             // persist changes
             if ($this->isNew()) {
                 $this->doInsert($con);
                 $affectedRows += 1;
             } else {
                 $affectedRows += $this->doUpdate($con);
             }
             $this->resetModified();
         }
         $this->alreadyInSave = false;
     }
     return $affectedRows;
 }
Ejemplo n.º 2
0
 private function updateActions(Module $model, ModuleSchema $module)
 {
     $actions = [];
     foreach ($module->getActionNames() as $name) {
         $action = $module->getAction($name);
         $a = new Action();
         $a->setName($name);
         $a->setModule($model);
         $a->setTitle($action->getTitle());
         $a->setDescription($action->getDescription());
         $a->setClassName($action->getClass());
         // add acl
         foreach ($action->getAcl() as $group) {
             $a->addGroup($this->getGroup($group));
         }
         $a->save();
         $actions[$name] = $a->getId();
     }
     // remove obsolete actions
     ActionQuery::create()->filterByModule($model)->where('Action.Name NOT IN ?', $module->getActionNames()->toArray())->delete();
     return $actions;
 }
Ejemplo n.º 3
0
 private function installActions(Module $module, $data)
 {
     if (!isset($data['actions'])) {
         return;
     }
     $actions = [];
     foreach ($data['actions'] as $name => $options) {
         $a = new Action();
         $a->setName($name);
         $a->setModule($module);
         if (isset($options['title'])) {
             $a->setTitle($options['title']);
         }
         if (isset($options['description'])) {
             $a->setDescription($options['description']);
         }
         if (isset($options['class'])) {
             $a->setClassName($options['class']);
         }
         // add acl
         if (isset($options['acl'])) {
             foreach ($options['acl'] as $group) {
                 $a->addGroup($this->getGroup($group));
             }
         }
         $a->save();
         $actions[$name] = $a->getId();
     }
     return $actions;
 }