Пример #1
0
 /**
  * Create the links for resources in the resource root
  * @return array the links, name => config
  */
 protected function createLinks()
 {
     $app = \Yii::app();
     /* @var \Restyii\Web\Application $app */
     $controller = $this->getController();
     $module = $controller->getModule();
     if (!$module) {
         $module = $app;
     }
     $controllers = $app->getSchema()->getControllerInstances($module);
     /* @var \Restyii\Controller\Base[]|\CController[] $controllers */
     $links = array('self' => array('title' => $module->name, 'href' => trim($app->getBaseUrl(), '/') . '/'));
     foreach ($controllers as $id => $controller) {
         if ($id === $module->defaultController) {
             continue;
         }
         $links[$id] = array('title' => method_exists($controller, 'classLabel') ? $controller->classLabel(true) : String::pluralize(String::humanize(substr(get_class($controller), 0, -10))), 'href' => $controller->createUrl('search'));
         if (method_exists($controller, 'classDescription')) {
             $links[$id]['description'] = $controller->classDescription();
         }
         if (isset($controller->modelClass)) {
             $links[$id]['profile'] = array($controller->modelClass);
         }
     }
     return $links;
 }
Пример #2
0
 /**
  * Returns the label for this resource type.
  *
  * @param bool $plural whether or not to pluralize the label, e.g. 'Users' instead of 'User'
  *
  * @return string the resource label
  */
 public function classLabel($plural = false)
 {
     if ($plural) {
         $label = String::humanize(String::pluralize(get_class($this)));
     } else {
         $label = get_class($this);
     }
     return $this->generateAttributeLabel($label);
 }
Пример #3
0
 /**
  * Return a label for the controller
  * @param bool $plural true if the plural form should be returned
  *
  * @return string the label
  */
 public function classLabel($plural = false)
 {
     $humanized = String::humanize(substr(get_class($this), 0, -10));
     return $plural ? String::pluralize($humanized) : $humanized;
 }