Пример #1
0
 function cast()
 {
     $this->model_name = AkInflector::camelize($this->model_name);
     $this->model_file_path = AkInflector::toModelFilename($this->model_name);
     if (empty($this->actions) && !empty($this->controller_name) && strstr($this->controller_name, ',')) {
         $this->controller_name = '';
     }
     $this->controller_name = empty($this->controller_name) ? AkInflector::pluralize($this->model_name) : AkInflector::camelize($this->controller_name);
     $this->controller_file_path = AkInflector::toControllerFilename($this->controller_name);
     $this->controller_class_name = str_replace(array('/', '::'), '_', $this->controller_name . 'Controller');
     $this->controller_name = AkInflector::demodulize($this->controller_name);
     $this->controller_human_name = AkInflector::humanize($this->controller_name);
     $this->helper_name = (AkInflector::is_plural($this->controller_name) ? AkInflector::singularize($this->controller_name) : $this->controller_name) . 'Helper';
     $this->helper_var_name = '$' . AkInflector::underscore($this->helper_name);
     $this->singular_name = AkInflector::underscore($this->model_name);
     $this->plural_name = AkInflector::pluralize($this->singular_name);
     $this->singular_controller_name = AkInflector::underscore($this->controller_name);
     $this->module_preffix = AkInflector::underscore(substr($this->controller_class_name, 0, strrpos($this->controller_class_name, '_')));
     $this->module_preffix = empty($this->module_preffix) ? '' : DS . $this->module_preffix;
     $this->files = array('controller.php' => $this->controller_file_path, 'helper.php' => AK_HELPERS_DIR . $this->module_preffix . DS . trim($this->helper_var_name, '$') . '.php', 'layout' => AK_VIEWS_DIR . DS . 'layouts' . DS . $this->singular_controller_name . '.tpl', 'view_add' => AK_VIEWS_DIR . $this->module_preffix . DS . $this->singular_controller_name . DS . 'add.tpl', 'view_destroy' => AK_VIEWS_DIR . $this->module_preffix . DS . $this->singular_controller_name . DS . 'destroy.tpl', 'view_edit' => AK_VIEWS_DIR . $this->module_preffix . DS . $this->singular_controller_name . DS . 'edit.tpl', 'view_listing' => AK_VIEWS_DIR . $this->module_preffix . DS . $this->singular_controller_name . DS . 'listing.tpl', 'view_show' => AK_VIEWS_DIR . $this->module_preffix . DS . $this->singular_controller_name . DS . 'show.tpl', 'form' => AK_VIEWS_DIR . $this->module_preffix . DS . $this->singular_controller_name . DS . '_form.tpl');
     $this->user_actions = array();
     foreach ((array) @$this->actions as $action) {
         $this->user_actions[$action] = AK_VIEWS_DIR . $this->module_preffix . DS . $this->singular_controller_name . DS . $action . '.tpl';
     }
 }
Пример #2
0
 function hasCollisions()
 {
     $this->_preloadPaths();
     $this->collisions = array();
     if (AkInflector::is_plural($this->class_name)) {
         $this->collisions[] = Ak::t('%class_name should be a singular noun', array('%class_name' => $this->class_name));
     }
     $files = array(AkInflector::toModelFilename($this->class_name), AK_TEST_DIR . DS . 'unit' . DS . 'app' . DS . 'models' . DS . $this->underscored_model_name . '.php', AK_TEST_DIR . DS . 'fixtures' . DS . $this->model_path, AK_TEST_DIR . DS . 'fixtures' . DS . $this->installer_path);
     foreach ($files as $file_name) {
         if (file_exists($file_name)) {
             $this->collisions[] = Ak::t('%file_name file already exists', array('%file_name' => $file_name));
         }
     }
     return count($this->collisions) > 0;
 }
Пример #3
0
 public function hasCollisions()
 {
     $this->_preloadPaths();
     $this->collisions = array();
     if (AkInflector::is_plural($this->class_name)) {
         $this->collisions[] = Ak::t('%class_name should be a singular noun', array('%class_name' => $this->class_name));
     }
     $files = array(AkInflector::toModelFilename($this->class_name), AkConfig::getDir('test') . DS . 'unit' . DS . $this->test_file_name);
     if (!$this->active_document) {
         $files[] = AkConfig::getDir('app_installers') . DS . $this->underscored_model_name . '_installer.php';
     }
     foreach ($files as $file_name) {
         if (file_exists($file_name)) {
             $this->collisions[] = Ak::t('%file_name file already exists', array('%file_name' => $file_name));
         }
     }
     return count($this->collisions) > 0;
 }
Пример #4
0
 function getCurrentControllerHelper()
 {
     $helper = $this->getControllerName();
     $helper = AkInflector::is_plural($helper) ? AkInflector::singularize($helper) : $helper;
     $helper_file_name = AK_HELPERS_DIR . DS . $this->_module_path . AkInflector::underscore($helper) . '_helper.php';
     if (file_exists($helper_file_name)) {
         return array($helper_file_name => $helper);
     }
     return array();
 }
Пример #5
0
 function test_should_detect_plurals()
 {
     foreach (array_values($this->SingularToPlural) as $plural) {
         $this->assertTrue(AkInflector::is_plural($plural), $plural . ' is not detected as plural');
     }
 }
Пример #6
0
 public function getCurrentControllerHelper()
 {
     $helper = $this->getControllerName();
     $helper = AkInflector::is_plural($helper) ? AkInflector::singularize($helper) : $helper;
     $helper_file_name = AkConfig::getDir('helpers') . DS . $this->getModulePath() . AkInflector::underscore($helper) . '_helper.php';
     if (file_exists($helper_file_name)) {
         return array($helper_file_name => $helper);
     }
     return array();
 }