Example #1
0
 public function deactivate($packageName)
 {
     if (array_key_exists($packageName, $this->activatedModules) && !array_key_exists($packageName, $this->installedModules)) {
         $mod = ModuleQuery::create()->filterByName($packageName)->findOne();
         $mod->setActivatedVersion(null);
         $mod->save();
         unset($this->activatedModules[$packageName]);
     }
 }
Example #2
0
 public function deactivate(IOInterface $io, $packageName)
 {
     $io->write('[Keeko] Deactivate Module: ' . $packageName);
     $model = ModuleQuery::create()->filterByName($packageName)->findOne();
     $model->setActivatedVersion(null);
     $model->save();
     // run module -> uninstall()
     $package = $this->getPackageSchema($packageName);
     $className = $package->getKeeko()->getModule()->getClass();
     $module = new $className($model, $this->service);
     $module->uninstall();
     $this->dispatcher->dispatch(ModuleEvent::DEACTIVATED, new ModuleEvent($model));
 }
 private function loadModules()
 {
     if (!empty($this->modules)) {
         return $this->modules;
     }
     $modules = [];
     $models = ModuleQuery::create()->filterByApi(true)->find();
     $repo = $this->service->getResourceRepository();
     foreach ($models as $model) {
         $package = $this->service->getPackageManager()->getPackage($model->getName());
         $filename = sprintf('/packages/%s/api.json', $model->getName());
         if ($repo->contains($filename)) {
             $routes = [];
             $json = Json::decode($repo->get($filename)->getBody());
             $swagger = new Swagger($json);
             foreach ($swagger->getPaths() as $path) {
                 /* @var $path Path */
                 foreach (Swagger::$METHODS as $method) {
                     if ($path->hasOperation($method)) {
                         $op = $path->getOperation($method);
                         $actionName = $op->getOperationId();
                         $routes[str_replace('-', '_', $actionName)] = ['method' => $method, 'path' => $path->getPath()];
                     }
                 }
             }
             $modules[] = ['title' => $model->getTitle(), 'slug' => $package->getKeeko()->getModule()->getSlug(), 'model' => $model, 'routes' => $routes];
         }
     }
     $this->modules = $modules;
     return $modules;
 }
Example #4
0
 /**
  * Gets a single ChildModule object, which is related to this object by a one-to-one relationship.
  *
  * @param  ConnectionInterface $con optional connection object
  * @return ChildModule
  * @throws PropelException
  */
 public function getModule(ConnectionInterface $con = null)
 {
     if ($this->singleModule === null && !$this->isNew()) {
         $this->singleModule = ChildModuleQuery::create()->findPk($this->getPrimaryKey(), $con);
     }
     return $this->singleModule;
 }
Example #5
0
 /**
  * Returns one Module with the given id from cache
  * 
  * @param mixed $id
  * @return Module|null
  */
 protected function get($id)
 {
     if ($this->pool === null) {
         $this->pool = new Map();
     } else {
         if ($this->pool->has($id)) {
             return $this->pool->get($id);
         }
     }
     $model = ModuleQuery::create()->findOneById($id);
     $this->pool->set($id, $model);
     return $model;
 }
Example #6
0
 /**
  * Performs an INSERT on the database, given a Module or Criteria object.
  *
  * @param mixed               $criteria Criteria or Module object containing data that is used to create the INSERT statement.
  * @param ConnectionInterface $con the ConnectionInterface connection to use
  * @return mixed           The new primary key.
  * @throws PropelException Any exceptions caught during processing will be
  *                         rethrown wrapped into a PropelException.
  */
 public static function doInsert($criteria, ConnectionInterface $con = null)
 {
     if (null === $con) {
         $con = Propel::getServiceContainer()->getWriteConnection(ModuleTableMap::DATABASE_NAME);
     }
     if ($criteria instanceof Criteria) {
         $criteria = clone $criteria;
         // rename for clarity
     } else {
         $criteria = $criteria->buildCriteria();
         // build Criteria from Module object
     }
     // Set the correct dbName
     $query = ModuleQuery::create()->mergeWith($criteria);
     // use transaction because $criteria could contain info
     // for more than one table (I guess, conceivably)
     return $con->transaction(function () use($con, $query) {
         return $query->doInsert($con);
     });
 }
Example #7
0
 /**
  * Get the associated ChildModule object
  *
  * @param  ConnectionInterface $con Optional Connection object.
  * @return ChildModule The associated ChildModule object.
  * @throws PropelException
  */
 public function getModule(ConnectionInterface $con = null)
 {
     if ($this->aModule === null && $this->module_id !== null) {
         $this->aModule = ChildModuleQuery::create()->findPk($this->module_id, $con);
         /* The following can be used additionally to
               guarantee the related object contains a reference
               to this object.  This level of coupling may, however, be
               undesirable since it could result in an only partially populated collection
               in the referenced object.
               $this->aModule->addActions($this);
            */
     }
     return $this->aModule;
 }
Example #8
0
 /**
  * Builds a Criteria object containing the primary key for this object.
  *
  * Unlike buildCriteria() this method includes the primary key values regardless
  * of whether or not they have been modified.
  *
  * @throws LogicException if no primary key is defined
  *
  * @return Criteria The Criteria object containing value(s) for primary key(s).
  */
 public function buildPkeyCriteria()
 {
     $criteria = ChildModuleQuery::create();
     $criteria->add(ModuleTableMap::COL_ID, $this->id);
     return $criteria;
 }
Example #9
0
 /**
  * Returns a new ChildModuleQuery object.
  *
  * @param     string $modelAlias The alias of a model in the query
  * @param     Criteria $criteria Optional Criteria to build the query from
  *
  * @return ChildModuleQuery
  */
 public static function create($modelAlias = null, Criteria $criteria = null)
 {
     if ($criteria instanceof ChildModuleQuery) {
         return $criteria;
     }
     $query = new ChildModuleQuery();
     if (null !== $modelAlias) {
         $query->setModelAlias($modelAlias);
     }
     if ($criteria instanceof Criteria) {
         $query->mergeWith($criteria);
     }
     return $query;
 }