Example #1
0
 /**
  * Generates different variations of the configured $this->model property name
  *
  * If no model is configured (i.e. `null`) - it automatically detects the corresponding
  * model for this Controller via Inflection and `Libraries::locate()`.
  *
  * @see lithium\core\Libraries::locate()
  * @param string $field defines, what variation of the default you want to have
  *               available are 'class', 'model', 'singular', 'plural' and 'table' and 'human'.
  *               if omitted, returns array containing all of them.
  * @return array|string
  **/
 protected function _scaffold($field = null)
 {
     if (is_null($this->model)) {
         $this->model = (string) Libraries::locate('models', $this->request->controller);
     }
     if (is_null($this->scaffold)) {
         $class = basename(str_replace('\\', '/', $this->model));
         $base = !empty($this->library) ? array('controller' => $this->controller, 'library' => $this->library) : array('controller' => $this->controller);
         $this->scaffold = array('base' => Router::match($base, $this->request), 'controller' => strtolower($this->controller), 'library' => $this->library, 'class' => $class, 'model' => $this->model, 'slug' => Inflector::underscore($class), 'singular' => Inflector::singularize($class), 'plural' => Inflector::pluralize($class), 'table' => Inflector::tableize($class), 'human' => Inflector::humanize($class));
     }
     if (!is_null($field)) {
         return isset($this->scaffold[$field]) ? $this->scaffold[$field] : false;
     }
     Environment::set(true, array('scaffold' => $this->scaffold));
     return $this->scaffold;
 }