setBundle() public method

public setBundle ( Bundle $bundle = null )
$bundle Bundle
コード例 #1
0
ファイル: Utils.php プロジェクト: jarves/jarves
 /**
  * Gets the item from the administration entry points defined in the config.json, by the given code.
  *
  * @param string  $code <bundleName>/news/foo/bar/edit
  *
  * @return EntryPoint
  */
 public function getEntryPoint($code)
 {
     if ('/' === $code) {
         return null;
     }
     $path = $code;
     if (substr($code, 0, 1) == '/') {
         $code = substr($code, 1);
     }
     if (false === strpos($code, '/')) {
         $path = '';
     }
     $bundleName = $code;
     if (false !== strpos($code, '/')) {
         $bundleName = substr($code, 0, strpos($code, '/'));
         $path = substr($code, strpos($code, '/') + 1);
     }
     //$bundleName = ucfirst($bundleName) . 'Bundle';
     $config = $this->jarves->getConfig($bundleName);
     if (!$path && $config) {
         //root
         $entryPoint = new EntryPoint();
         $entryPoint->setType(0);
         $entryPoint->setPath($code);
         $entryPoint->setChildren($config->getEntryPoints());
         $entryPoint->setBundle($config);
         return $entryPoint;
     }
     $entryPoint = null;
     if ($config) {
         while (!($entryPoint = $config->getEntryPoint($path))) {
             if (false === strpos($path, '/')) {
                 break;
             }
             $path = substr($path, 0, strrpos($path, '/'));
         }
     }
     return $entryPoint;
 }