Example #1
0
 /**
  * Will restrict results to $model records
  * associated with $descendantModel->$descendantId record
  */
 public function whereDescendantId($descendantRecordModel, $descendantRecordId, $model)
 {
     if (!($module = self::$moduleManager->getModuleByModel($model))) {
         throw new dmException(sprintf('No module %s', $model));
     }
     if ($descendantRecordModel == $model) {
         return $this->addWhere($this->getRootAlias() . '.id = ?', $descendantRecordId);
     }
     if (!($descendantModule = $module->getDescendant($descendantRecordModel))) {
         throw new dmRecordException(sprintf('%s is not an descendant of %s', $descendantRecordModel, $module));
     }
     $parent = $module;
     $parentAlias = $this->getRootAlias();
     foreach ($descendantModule->getPathFrom($module, true) as $descendantKey => $descendant) {
         if ($descendantKey != $module->getKey()) {
             if (!($relation = $parent->getTable()->getRelationHolder()->getByClass($descendant->getModel()))) {
                 throw new dmRecordException(sprintf('%s has no relation for class %s', $parent, $descendant->getModel()));
             }
             $this->leftJoin($parentAlias . '.' . $relation['alias'] . ' ' . $descendantKey);
             if ($descendant->is($module)) {
                 break;
             }
             $parent = $descendant;
             $parentAlias = $descendantKey;
         }
     }
     $this->addWhere($descendantModule->getKey() . '.id = ?', $descendantRecordId);
     return $this;
 }
Example #2
0
 public function execute(array $onlyModules = array())
 {
     if (empty($onlyModules)) {
         $onlyModules = $this->moduleManager->getProjectModules();
     } elseif (is_string(dmArray::first($onlyModules))) {
         $onlyModules = $this->moduleManager->keysToModules($onlyModules);
     }
     $onlyModules = dmModuleManager::removeModulesChildren($onlyModules);
     $this->updateListPages();
     $this->removeShowPages($onlyModules);
     $this->updateShowPages($onlyModules);
 }
Example #3
0
 public function execute(array $onlyModules, $culture)
 {
     $this->setCulture($culture);
     $recordDefaultCulture = myDoctrineRecord::getDefaultCulture();
     myDoctrineRecord::setDefaultCulture($this->culture);
     if (empty($onlyModules)) {
         $onlyModules = $this->moduleManager->getProjectModules();
     } elseif (is_string(dmArray::first($onlyModules))) {
         $onlyModules = $this->moduleManager->keysToModules($onlyModules);
     }
     $onlyModules = dmModuleManager::removeModulesChildren($onlyModules);
     foreach ($onlyModules as $module) {
         $this->updateRecursive($module);
     }
     myDoctrineRecord::setDefaultCulture($recordDefaultCulture);
 }