コード例 #1
0
ファイル: Publish.php プロジェクト: radnan/rdn-asset
 /**
  * Iterate over each module and publish its assets.
  *
  * @param InputInterface $input
  * @param OutputInterface $output
  */
 protected function doPublish(InputInterface $input, OutputInterface $output)
 {
     $output->writeln('<info>Publishing module assets</info>');
     $nothing = true;
     $moduleName = $input->getOption('module');
     if ($moduleName) {
         $moduleNames = array($moduleName);
     } else {
         $moduleNames = $this->modules->getModules();
     }
     $inflector = new CamelCaseToDash();
     foreach ($moduleNames as $moduleName) {
         $source = $this->getPublicPath($moduleName);
         if ($source === false) {
             continue;
         }
         $output->writeln(" - <comment>{$moduleName}</comment>");
         $basename = strtolower($inflector->filter($moduleName));
         $this->publisher->publish($source, $basename);
         $nothing = false;
     }
     if ($nothing) {
         $output->writeln('Nothing to publish');
     }
 }
コード例 #2
0
ファイル: PageDataMapper.php プロジェクト: spryker/Search
 /**
  * @param string $key
  *
  * @throws \Spryker\Zed\Search\Business\Exception\InvalidPropertyNameException
  *
  * @return string
  */
 protected function normalizeKey($key)
 {
     if (in_array($key, $this->pageIndexMap->getProperties())) {
         return $key;
     }
     $normalizedKey = $this->underscoreToDashFilter->filter($key);
     if (in_array($normalizedKey, $this->pageIndexMap->getProperties())) {
         return $normalizedKey;
     }
     throw new InvalidPropertyNameException(sprintf('Unable to map %s property in %s', $key, get_class($this->pageIndexMap)));
 }
コード例 #3
0
ファイル: CreateController.php プロジェクト: acplo/acplobase
    public function crudAction()
    {
        $console = $this->getServiceLocator()->get('console');
        $tmpDir = sys_get_temp_dir();
        $request = $this->getRequest();
        $name = $request->getParam('name');
        $path = rtrim($request->getParam('path'), '/');
        if (empty($path)) {
            $path = '.';
        }
        if (!file_exists("{$path}/module") || !file_exists("{$path}/config/application.config.php")) {
            return $this->sendError("The path {$path} doesn't contain a ZF2 application. I cannot create a module here.");
        }
        if (file_exists("{$path}/module/{$name}")) {
            return $this->sendError("The module {$name} already exists.");
        }
        $filter = new CamelCaseToDashFilter();
        $viewfolder = strtolower($filter->filter($name));
        $name = ucfirst($name);
        mkdir("{$path}/module/{$name}/config", 0777, true);
        mkdir("{$path}/module/{$name}/src/{$name}/Controller", 0777, true);
        mkdir("{$path}/module/{$name}/src/{$name}/Entity", 0777, true);
        mkdir("{$path}/module/{$name}/src/{$name}/Service", 0777, true);
        mkdir("{$path}/module/{$name}/view/{$viewfolder}/crud", 0777, true);
        $crudDir = __DIR__ . '/../../../data/crud';
        $files = ["config/module.config.php" => "config/module.config.php", "autoload_classmap.php" => "autoload_classmap.php", "autoload_function.php" => "autoload_function.php", "autoload_register.php" => "autoload_register.php", "Module.php" => "Module.php", "src/{$name}/Controller/CrudController.php" => "src/LosCrudModule/Controller/CrudController.php", "src/{$name}/Entity/{$name}.php" => "src/LosCrudModule/Entity/Entity.php", "src/{$name}/Module.php" => "src/LosCrudModule/Module.php", "src/{$name}/Service/{$name}.php" => "src/LosCrudModule/Service/Entity.php", "view/{$viewfolder}/crud/add.phtml" => "view/los-crud-module/crud/add.phtml", "view/{$viewfolder}/crud/delete.phtml" => "view/los-crud-module/crud/delete.phtml", "view/{$viewfolder}/crud/edit.phtml" => "view/los-crud-module/crud/edit.phtml", "view/{$viewfolder}/crud/list.phtml" => "view/los-crud-module/crud/list.phtml"];
        foreach ($files as $destFile => $origFile) {
            \file_put_contents("{$path}/module/{$name}/{$destFile}", $this->handleFile($crudDir . "/{$origFile}", $name, $viewfolder));
        }
        // Add the module in application.config.php
        $application = (require "{$path}/config/application.config.php");
        if (!in_array($name, $application['modules'])) {
            $application['modules'][] = $name;
            copy("{$path}/config/application.config.php", "{$path}/config/application.config.old");
            $content = <<<EOD
<?php
/**
 * Configuration file changed by AcploBase
 * The previous configuration file is stored in application.config.old
 */

EOD;
            $generator = new ValueGenerator();
            $generator->setValue($application);
            $content .= 'return ' . $generator . ";\n";
            file_put_contents("{$path}/config/application.config.php", $content);
        }
        if ($path === '.') {
            $console->writeLine("The module {$name} has been created", Color::GREEN);
        } else {
            $console->writeLine("The module {$name} has been created in {$path}", Color::GREEN);
        }
    }
コード例 #4
0
ファイル: ClassParser.php プロジェクト: robertodormepoco/zf2
 /**
  * Retrieve DocBook ID for this class
  *
  * @return string
  */
 public function getId()
 {
     if (null !== $this->id) {
         return $this->id;
     }
     $class = $this->reflection->getName();
     $id = '';
     $filter = new CamelCaseToDashFilter();
     foreach (explode('\\', $class) as $segment) {
         $id .= $filter->filter($segment) . '.';
     }
     $id = strtolower(rtrim($id, '.'));
     $this->id = $id;
     return $this->id;
 }
コード例 #5
0
ファイル: ClassMethod.php プロジェクト: brikou/zend_docbook
 /**
  * Get normalized method identifier
  *
  * @return string
  */
 public function getId()
 {
     if (null !== $this->id) {
         return $this->id;
     }
     $namespace = $this->getNamespace();
     $class = $this->getClass();
     $name = $this->getName();
     $id = '';
     $filter = new CamelCaseToDashFilter();
     foreach (explode('\\', $namespace) as $segment) {
         $id .= $filter->filter($segment) . '.';
     }
     $id .= $filter->filter($class) . '.methods.' . $filter->filter($name);
     $this->id = strtolower($id);
     return $this->id;
 }
コード例 #6
0
 /**
  * Inflect a name to a normalized value.
  *
  * @param string $name
  * @return string
  */
 private function inflectName($name)
 {
     if (!$this->inflector) {
         $this->inflector = new CamelCaseToDash();
     }
     $name = $this->inflector->filter($name);
     return strtolower($name);
 }
コード例 #7
0
 /**
  * @param array $composerJson
  * @param \Symfony\Component\Finder\SplFileInfo $composerJsonFile
  *
  * @return array
  */
 public function update(array $composerJson, SplFileInfo $composerJsonFile)
 {
     $bundleName = $this->getBundleName($composerJson);
     $dependentBundles = $this->getDependentBundles($bundleName);
     if (!Config::hasValue(DevelopmentConstants::COMPOSER_REQUIRE_VERSION)) {
         return $composerJson;
     }
     $composerRequireVersion = Config::get(DevelopmentConstants::COMPOSER_REQUIRE_VERSION);
     if (preg_match('/^[0-9]/', $composerRequireVersion)) {
         $composerRequireVersion = self::RELEASE_OPERATOR . $composerRequireVersion;
     }
     foreach ($dependentBundles as $dependentBundle) {
         $filter = new CamelCaseToDash();
         $dependentBundle = strtolower($filter->filter($dependentBundle));
         $composerJson[self::KEY_REQUIRE]['spryker/' . $dependentBundle] = $composerRequireVersion;
     }
     return $composerJson;
 }
コード例 #8
0
ファイル: Console.php プロジェクト: hjr3/zf2
 /**
  * convertToClientNaming()
  *
  * Convert words to client specific naming, in this case is lower, dash separated
  *
  * Filters are lazy-loaded.
  *
  * @param string $string
  * @return string
  */
 public function convertToClientNaming($string)
 {
     if (!$this->_filterToClientNaming) {
         $filter = new \Zend\Filter\FilterChain();
         $filter->attach(new \Zend\Filter\Word\CamelCaseToDash());
         $filter->attach(new \Zend\Filter\StringToLower());
         $this->_filterToClientNaming = $filter;
     }
     return $this->_filterToClientNaming->filter($string);
 }
コード例 #9
0
ファイル: Filesystem.php プロジェクト: spryker/Library
 /**
  * {@inheritdoc}
  * @throws \Twig_Error_Loader
  */
 protected function findTemplate($name)
 {
     $name = (string) $name;
     // normalize name
     $name = str_replace(['///', '//', '\\'], '/', $name);
     $nameParts = explode('/', $name);
     $templateName = array_pop($nameParts);
     $filter = new CamelCaseToDash();
     $templateName = strtolower($filter->filter($templateName));
     array_push($nameParts, $templateName);
     $name = implode('/', $nameParts);
     if (isset($this->cache[$name])) {
         if ($this->cache[$name] !== false) {
             return $this->cache[$name];
         } else {
             throw new Twig_Error_Loader(sprintf('Unable to find template "%s" (cached).', $name));
         }
     }
     $this->validateName($name);
     if (isset($name[0]) && $name[0] === '@') {
         $pos = strpos($name, '/');
         if ($pos === false) {
             $this->cache[$name] = false;
             throw new Twig_Error_Loader(sprintf('Malformed bundle template name "%s" (expecting "@bundle/template_name").', $name));
         }
         $bundle = ucfirst(substr($name, 1, $pos - 1));
         $templateName = ucfirst(substr($name, $pos + 1));
         return $this->load($name, $bundle, $templateName);
     }
     $name = '/' . ltrim($name, '/');
     $pos = strpos(ltrim($name, '/'), '/');
     if ($pos === false) {
         $this->cache[$name] = false;
         throw new Twig_Error_Loader(sprintf('Malformed bundle template name "%s" (expecting "@bundle/template_name").', $name));
     }
     $bundle = ucfirst(substr($name, 1, $pos));
     $templateName = ucfirst(substr($name, $pos + 2));
     return $this->load($name, $bundle, $templateName);
 }
コード例 #10
0
 /**
  * Loads available actions of a controller.
  */
 public function loadActionsAction()
 {
     if (false == $this->getRequest()->isPost()) {
         return false;
     }
     // Get controller
     $controller = $this->params()->fromPost('controller');
     // Fetch actions aof this controller
     $controllerInstance = $this->getServiceLocator()->get('controllermanager')->get($controller);
     $methods = get_class_methods($controllerInstance);
     $actions = array_filter($methods, function ($item) {
         if (preg_match('#Action$#', $item) && 'notFoundAction' != $item && 'getMethodFromAction' != $item) {
             return true;
         }
         return false;
     });
     // Sort
     sort($actions);
     $filter = new CamelCaseToDash();
     $actions = array_map(function ($method) use($filter) {
         $action = preg_replace('#^(.*?)Action$#u', '$1', $method);
         $action = $filter->filter($action);
         return $action;
     }, $actions);
     // View
     return new JsonModel(compact(['actions']));
 }
コード例 #11
0
ファイル: LayoutSchemeService.php プロジェクト: klaid83/ms
 /**
  * @param array  $templates
  * @param string $key
  *
  * @return bool
  */
 protected function applyLayout(GenericOptions $layoutOptions, $applyContent = false)
 {
     $layout = $this->getServiceLocator()->get('view_manager')->getViewModel();
     $layoutRoot = $layoutOptions->getLayout();
     if ($layoutRoot) {
         $layout->setTemplate($layoutRoot);
     }
     $filter = new CamelCaseToDash();
     foreach ($layoutOptions as $capture => $template) {
         if ($capture === 'layout') {
             continue;
         }
         if ($applyContent === false && $capture === 'content') {
             $this->contentTemplate = $layoutOptions->getContent();
             continue;
         }
         switch ($template) {
             case null:
             case '<default>':
                 $template = strtolower($filter->filter($this->getParam('module') . '\\' . $this->getParam('controller') . '\\' . $this->getParam('action') . '-' . $capture));
                 break;
             case '<none>':
                 $template = null;
                 break;
             default:
                 break;
         }
         if (!$template) {
             continue;
         }
         $view = new ViewModel();
         $view->setTemplate($template);
         $layout->addChild($view, $capture);
         // keep reference for controller plugin use
         $this->setChildViewModel($capture, $view);
     }
     return true;
 }
コード例 #12
0
 private function methodToActionName($methodName)
 {
     $filter = new CamelCaseToDash();
     $methodName = preg_replace('/Action$/', '', $methodName);
     return strtolower($filter->filter($methodName));
 }
コード例 #13
0
    public function moduleAction()
    {
        $console = $this->getServiceLocator()->get('console');
        $tmpDir = sys_get_temp_dir();
        $request = $this->getRequest();
        $name = $request->getParam('name');
        $path = rtrim($request->getParam('path'), '/');
        if (empty($path)) {
            $path = '.';
        }
        if (!file_exists("{$path}/module") || !file_exists("{$path}/config/application.config.php")) {
            return $this->sendError("The path {$path} doesn't contain a ZF2 application. I cannot create a module here.");
        }
        if (file_exists("{$path}/module/{$name}")) {
            return $this->sendError("The module {$name} already exists.");
        }
        $filter = new CamelCaseToDashFilter();
        $viewfolder = strtolower($filter->filter($name));
        $name = ucfirst($name);
        mkdir("{$path}/module/{$name}/config", 0777, true);
        mkdir("{$path}/module/{$name}/src/{$name}/Controller", 0777, true);
        mkdir("{$path}/module/{$name}/view/{$viewfolder}", 0777, true);
        // Create the Module.php
        file_put_contents("{$path}/module/{$name}/Module.php", Skeleton::getModule($name));
        // Create the module.config.php
        file_put_contents("{$path}/module/{$name}/config/module.config.php", Skeleton::getModuleConfig($name));
        // Add the module in application.config.php
        $application = (require "{$path}/config/application.config.php");
        if (!in_array($name, $application['modules'])) {
            $application['modules'][] = $name;
            copy("{$path}/config/application.config.php", "{$path}/config/application.config.old");
            $content = <<<EOD
<?php
/**
 * Configuration file generated by ZFTool
 * The previous configuration file is stored in application.config.old
 *
 * @see https://github.com/zendframework/ZFTool
 */

EOD;
            $content .= 'return ' . Skeleton::exportConfig($application) . ";\n";
            file_put_contents("{$path}/config/application.config.php", $content);
        }
        if ($path === '.') {
            $console->writeLine("The module {$name} has been created", Color::GREEN);
        } else {
            $console->writeLine("The module {$name} has been created in {$path}", Color::GREEN);
        }
    }