getBundleDir() public method

public getBundleDir ( string $bundleName ) : string | null
$bundleName string full className or bundleName or short bundleName
return string | null with leading / relative to root folder
Ejemplo n.º 1
0
 /**
  * @param string $bundle
  * @param string $lang
  * @return array
  */
 protected function getLanguage($bundle, $lang)
 {
     Manager::prepareName($bundle);
     $utils = $this->translator->getUtils();
     $file = $this->jarves->getBundleDir($bundle) . "Resources/translations/{$lang}.po";
     $res = $utils->parsePo($file);
     $pluralForm = $utils->getPluralForm($lang);
     preg_match('/^nplurals=([0-9]+);/', $pluralForm, $match);
     $res['pluralCount'] = intval($match[1]);
     $res['pluralForm'] = $pluralForm;
     return $res;
 }
Ejemplo n.º 2
0
 /**
  * @ApiDoc(
  *  section="Bundle/Package Manager",
  *  description="Uninstalls a bundle"
  * )
  *
  * Removes relevant data and object's data. Executes also the uninstall script.
  * Removes database values, some files etc.
  *
  * @Rest\QueryParam(name="bundle", requirements=".+", strict=true, description="The bundle name")
  * @Rest\QueryParam(name="removeFiles", requirements=".+", default="true", description="If the orm should be updated")
  * @Rest\QueryParam(name="ormUpdate", requirements=".+", default="false", description="If the orm should be updated")
  *
  * @Rest\Post("/admin/system/bundle/manager/install")
  *
  * @param string $bundle
  * @param bool $ormUpdate
  * @param bool $removeFiles
  *
  * @throws BundleNotFoundException
  * @return bool
  */
 public function uninstallAction($bundle, $ormUpdate = null, $removeFiles = null)
 {
     $ormUpdate = filter_var($ormUpdate, FILTER_VALIDATE_BOOLEAN);
     $removeFiles = filter_var($removeFiles, FILTER_VALIDATE_BOOLEAN);
     Manager::prepareName($bundle);
     $fs = $this->localFilesystem;
     $path = $this->jarves->getBundleDir($bundle);
     if (!$path) {
         throw new \Jarves\Exceptions\BundleNotFoundException();
     }
     $hasPropelModels = $fs->has($path . 'Resources/config/model.xml');
     $this->firePackageManager($bundle, 'uninstall');
     $this->deactivateAction($bundle);
     //fire update propel orm
     if ($ormUpdate && $hasPropelModels) {
         //update propel
         if ($ormUpdate) {
             $this->jarves->getEventDispatcher()->dispatch('core/bundle/schema-update', $bundle);
         }
     }
     //remove files
     if (filter_var($removeFiles, FILTER_VALIDATE_BOOLEAN)) {
         $fs->delete($path);
         if (0 === strpos($path, $this->getComposerVendorDir())) {
             $path = explode('/', $path);
             $composerName = $path[1] . '/' . $path[2];
             $this->uninstallComposerAction($composerName);
         }
     }
     return true;
 }
Ejemplo n.º 3
0
 /**
  * @ApiDoc(
  *  section="Bundle Editor",
  *  description="Creates a new CRUD object window class"
  * )
  *
  * @Rest\RequestParam(name="class", requirements=".*", strict=true, description="The PHP class name")
  * @Rest\RequestParam(name="bundle", requirements=".*", strict=true, description="The bundle name")
  * @Rest\RequestParam(name="force", requirements=".*", default="false", description="Overwrites existing")
  *
  * @Rest\Put("/admin/system/bundle/editor/window")
  *
  * @param ParamFetcher $paramFetcher
  *
  * @return bool
  * @throws FileAlreadyExistException
  */
 public function createWindowAction(ParamFetcher $paramFetcher)
 {
     $class = $paramFetcher->get('class');
     $bundle = $paramFetcher->get('bundle');
     $force = filter_var($paramFetcher->get('force'), FILTER_VALIDATE_BOOLEAN);
     if (substr($class, 0, 1) != '\\') {
         $class = '\\' . $class;
     }
     if (class_exists($class) && !$force) {
         $reflection = new \ReflectionClass($class);
         throw new FileAlreadyExistException(sprintf('Class already exist in %s', $reflection->getFileName()));
     }
     $actualPath = str_replace('\\', '/', substr($class, 1)) . '.php';
     $actualPath = $this->jarves->getBundleDir($bundle) . $actualPath;
     if (file_exists($actualPath) && !$force) {
         throw new FileAlreadyExistException(sprintf('File already exist, %s', $actualPath));
     }
     $sourcecode = "<?php\n\n";
     $bundle = $this->jarves->getBundle($bundle);
     $lSlash = strrpos($class, '\\');
     $class2Name = $lSlash !== -1 ? substr($class, $lSlash + 1) : $class;
     $parentClass = '\\Jarves\\Admin\\ObjectCrud';
     $namespace = ucfirst($bundle->getNamespace()) . substr($class, 0, $lSlash);
     if (substr($namespace, -1) == '\\') {
         $namespace = substr($namespace, 0, -1);
     }
     $sourcecode .= "namespace {$namespace};\n \n";
     $sourcecode .= 'class ' . $class2Name . ' extends ' . $parentClass . " {\n\n";
     $sourcecode .= "}\n";
     $fs = $this->localFilesystem;
     $result = $fs->write($actualPath, $sourcecode);
     $this->reconfigureJarves();
     return $result;
 }
Ejemplo n.º 4
0
 public function getComposerArray($bundleClass)
 {
     $path = $this->jarves->getBundleDir($bundleClass);
     $fs = $this->localFilesystem;
     if ($fs->has($file = $path . '/composer.json')) {
         return json_decode($fs->read($file), true);
     }
 }