Esempio n. 1
0
 /**
  * Applies methods set from hooks to an object in __construct()
  *
  * @param string $configKey
  */
 public static function applyHookMethods($configKey, &$object = null)
 {
     if (empty($object)) {
         $object = self;
     }
     if ($object instanceof Table) {
         $objectName = $object->alias();
     } else {
         $objectName = $object->name;
     }
     if (php_sapi_name() !== 'cli') {
         $prefix = ($prefix = Router::getRequest()->param('prefix')) ? Inflector::camelize($prefix) . '.' : '';
         $plugin = ($plugin = Router::getRequest()->param('plugin')) ? $plugin . '.' : '';
         $objectName = $prefix . $plugin . $objectName;
         $hookMethods = Configure::read($configKey . '.' . $objectName);
         if (is_array(Configure::read($configKey . '.*'))) {
             $hookMethods = Hash::merge(Configure::read($configKey . '.*'), $hookMethods);
         }
         if (is_array($hookMethods)) {
             foreach ($hookMethods as $method => $values) {
                 if (is_callable([$object, $method])) {
                     foreach ($values as $name => $config) {
                         $object->{$method}($name, $config);
                     }
                 }
             }
         }
     }
 }
Esempio n. 2
0
 /**
  * Index method
  *
  * @param string $filter Parameter to filter on
  * @param string $id Id of the model to filter
  *
  * @return \Cake\Network\Response|void
  */
 public function index($filter = null, $id = null)
 {
     $findOptions = ['fields' => ['id', 'name', 'description', 'created', 'modified', 'sfw', 'status', 'user_id'], 'conditions' => ['Albums.status' => 1], 'contain' => ['Users' => ['fields' => ['id', 'username', 'realname']], 'Languages' => ['fields' => ['id', 'name', 'iso639_1']], 'Projects' => ['fields' => ['id', 'name', 'ProjectsAlbums.album_id']], 'Files' => ['fields' => ['id', 'name', 'filename', 'sfw', 'AlbumsFiles.album_id'], 'conditions' => ['status' => STATUS_PUBLISHED]]], 'order' => ['created' => 'desc'], 'sortWhitelist' => ['created', 'name', 'modified']];
     // Sfw condition
     if (!$this->request->session()->read('seeNSFW')) {
         $findOptions['conditions']['sfw'] = true;
     }
     // Other conditions:
     if (!is_null($filter)) {
         switch ($filter) {
             case 'language':
                 $findOptions['conditions']['Languages.id'] = $id;
                 break;
             case 'license':
                 $findOptions['conditions']['Licenses.id'] = $id;
                 break;
             case 'user':
                 $findOptions['conditions']['Users.id'] = $id;
                 break;
             default:
                 throw new \Cake\Network\Exception\NotFoundException();
         }
         // Get additionnal infos infos
         $modelName = \Cake\Utility\Inflector::camelize(\Cake\Utility\Inflector::pluralize($filter));
         $FilterModel = \Cake\ORM\TableRegistry::get($modelName);
         $filterData = $FilterModel->get($id);
         $this->set('filterData', $filterData);
     }
     $this->set('filter', $filter);
     $this->paginate = $findOptions;
     $this->set('albums', $this->paginate($this->Albums));
     $this->set('_serialize', ['files']);
 }
Esempio n. 3
0
 /**
  * Get the action path for a given request. Primarily used by authorize objects
  * that need to get information about the plugin, controller, and action being invoked.
  *
  * @param \Cake\Network\Request $request The request a path is needed for.
  * @param string $path Path
  * @return string The action path for the given request.
  */
 public function action(Request $request, $path = '/:plugin/:controller/:action')
 {
     $plugin = empty($request['plugin']) ? null : Inflector::camelize($request['plugin']) . '/';
     $path = str_replace(array(':controller', ':action', ':plugin/'), array(Inflector::camelize($request['controller']), $request['action'], $plugin), $this->_config['actionPath'] . $path);
     $path = str_replace('//', '/', $path);
     return trim($path, '/');
 }
Esempio n. 4
0
 private function _jsonData($obj)
 {
     if (!$obj instanceof AppEntity) {
         return $obj;
     }
     $class = $obj->getClass();
     $result = [];
     $result['class'] = $class;
     $result['url'] = $obj->getUrl();
     foreach ($obj->visibleProperties() as $key) {
         $value = $obj->get($key);
         $label = Inflector::camelize("label_" . $key);
         if (method_exists($obj, $label)) {
             $value = call_user_func([$obj, $label], $value);
         }
         if (isset($this->_aliases[$class][$key])) {
             $key = $this->_aliases[$class][$key];
         }
         if (is_array($value)) {
             $value = $this->_jsonList($value, $obj, $key);
             unset($value['parent']);
         } else {
             $value = $this->_jsonCompact($value, $obj);
         }
         $result[$key] = $value;
     }
     return $result;
 }
 /**
  * Get controller to use, either plugin controller or application controller
  *
  * @param \Cake\Network\Request $request Request object
  * @param \Cake\Network\Response $response Response for the controller.
  * @return mixed name of controller if not loaded, or object if loaded
  */
 protected function _getController($request, $response)
 {
     $pluginPath = $controller = null;
     $namespace = 'Controller';
     if (!empty($request->params['plugin'])) {
         $pluginPath = $request->params['plugin'] . '.';
     }
     if ($pluginPath) {
         return parent::_getController($request, $response);
     }
     if (!empty($request->params['controller'])) {
         $controller = $request->params['controller'];
     }
     if (!empty($request->params['prefix'])) {
         $namespace .= '/' . Inflector::camelize($request->params['prefix']);
     }
     $className = false;
     if ($pluginPath . $controller) {
         $className = App::classname($pluginPath . $controller, $namespace, 'Controller');
     }
     if (!$className) {
         return false;
     }
     $instance = PipingBag::get($className);
     if (method_exists($instance, 'viewBuilder')) {
         $instance->viewBuilder();
     } else {
         $instance->viewPath = null;
     }
     $instance->name = $controller;
     $instance->setRequest($request);
     $instance->response = $response;
     return $instance;
 }
 /**
  * Get/Create an instance from the registry.
  *
  * When getting an instance, if it does not already exist,
  * a new instance will be created using the provide alias, and options.
  *
  * @param string $alias The name of the alias to get.
  * @param array $options Configuration options for the type constructor.
  * @return \Cake\ElasticSearch\Type
  */
 public static function get($alias, array $options = [])
 {
     if (isset(static::$instances[$alias])) {
         if (!empty($options) && static::$options[$alias] !== $options) {
             throw new RuntimeException(sprintf('You cannot configure "%s", it already exists in the registry.', $alias));
         }
         return static::$instances[$alias];
     }
     static::$options[$alias] = $options;
     list(, $classAlias) = pluginSplit($alias);
     $options = $options + ['name' => Inflector::underscore($classAlias)];
     if (empty($options['className'])) {
         $options['className'] = Inflector::camelize($alias);
     }
     $className = App::className($options['className'], 'Model/Type', 'Type');
     if ($className) {
         $options['className'] = $className;
     } else {
         if (!isset($options['name']) && strpos($options['className'], '\\') === false) {
             list(, $name) = pluginSplit($options['className']);
             $options['name'] = Inflector::underscore($name);
         }
         $options['className'] = 'Cake\\ElasticSearch\\Type';
     }
     if (empty($options['connection'])) {
         $connectionName = $options['className']::defaultConnectionName();
         $options['connection'] = ConnectionManager::get($connectionName);
     }
     static::$instances[$alias] = new $options['className']($options);
     return static::$instances[$alias];
 }
 /**
  * Get controller to use, either plugin controller or application controller
  *
  * @param \Cake\Network\Request $request Request object
  * @param \Cake\Network\Response $response Response for the controller.
  * @return mixed name of controller if not loaded, or object if loaded
  */
 protected function _getController($request, $response)
 {
     $pluginPath = $controller = null;
     $namespace = 'Controller';
     if (!empty($request->params['plugin'])) {
         $pluginPath = $request->params['plugin'] . '.';
     }
     if (!empty($request->params['controller'])) {
         $controller = $request->params['controller'];
     }
     if (!empty($request->params['prefix'])) {
         $namespace .= '/' . Inflector::camelize($request->params['prefix']);
     }
     $className = false;
     if ($pluginPath . $controller) {
         $className = App::classname($pluginPath . $controller, $namespace, 'Controller');
     }
     if (!$className) {
         return false;
     }
     $reflection = new \ReflectionClass($className);
     if ($reflection->isAbstract() || $reflection->isInterface()) {
         return false;
     }
     return $reflection->newInstance($request, $response);
 }
 /**
  * Social login link
  *
  * @param string $name
  * @param array $options
  * @return string
  */
 public function socialLogin($name, $options = [])
 {
     if (empty($options['label'])) {
         $options['label'] = 'Sign in with';
     }
     return $this->Html->link($this->Html->tag('i', '', ['class' => __d('Users', 'fa fa-{0}', strtolower($name))]) . __d('Users', '{0} {1}', Hash::get($options, 'label'), Inflector::camelize($name)), "/auth/{$name}", ['escape' => false, 'class' => __d('Users', 'btn btn-social btn-{0} ' . Hash::get($options, 'class') ?: '', strtolower($name))]);
 }
Esempio n. 9
0
 /**
  * Inits PO file from POT file.
  *
  * @param string|null $language Language code to use.
  * @return int|null
  */
 public function init($language = null)
 {
     if (!$language) {
         $language = $this->in('Please specify language code, e.g. `en`, `eng`, `en_US` etc.');
     }
     if (strlen($language) < 2) {
         return $this->error('Invalid language code. Valid is `en`, `eng`, `en_US` etc.');
     }
     $this->_paths = [APP];
     if ($this->param('plugin')) {
         $plugin = Inflector::camelize($this->param('plugin'));
         $this->_paths = [Plugin::classPath($plugin)];
     }
     $response = $this->in('What folder?', null, rtrim($this->_paths[0], DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . 'Locale');
     $sourceFolder = rtrim($response, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR;
     $targetFolder = $sourceFolder . $language . DIRECTORY_SEPARATOR;
     if (!is_dir($targetFolder)) {
         mkdir($targetFolder, 0775, true);
     }
     $count = 0;
     $iterator = new DirectoryIterator($sourceFolder);
     foreach ($iterator as $fileinfo) {
         if (!$fileinfo->isFile()) {
             continue;
         }
         $filename = $fileinfo->getFilename();
         $newFilename = $fileinfo->getBasename('.pot');
         $newFilename = $newFilename . '.po';
         $this->createFile($targetFolder . $newFilename, file_get_contents($sourceFolder . $filename));
         $count++;
     }
     $this->out('Generated ' . $count . ' PO files in ' . $targetFolder);
 }
 /**
  * Create a controller for a given request/response
  *
  * @param \Cake\Network\Request $request The request to build a controller for.
  * @param \Cake\Network\Response $response The response to use.
  * @return \Cake\Controller\Controller
  */
 public function create(Request $request, Response $response)
 {
     $pluginPath = $controller = null;
     $namespace = 'Controller';
     if (isset($request->params['plugin'])) {
         $pluginPath = $request->params['plugin'] . '.';
     }
     if (isset($request->params['controller'])) {
         $controller = $request->params['controller'];
     }
     if (isset($request->params['prefix'])) {
         if (strpos($request->params['prefix'], '/') === false) {
             $namespace .= '/' . Inflector::camelize($request->params['prefix']);
         } else {
             $prefixes = array_map('Cake\\Utility\\Inflector::camelize', explode('/', $request->params['prefix']));
             $namespace .= '/' . implode('/', $prefixes);
         }
     }
     $firstChar = substr($controller, 0, 1);
     if (strpos($controller, '\\') !== false || strpos($controller, '.') !== false || $firstChar === strtolower($firstChar)) {
         return $this->missingController($request);
     }
     $className = false;
     if ($pluginPath . $controller) {
         $className = App::classname($pluginPath . $controller, $namespace, 'Controller');
     }
     if (!$className) {
         return $this->missingController($request);
     }
     $reflection = new ReflectionClass($className);
     if ($reflection->isAbstract() || $reflection->isInterface()) {
         return $this->missingController($request);
     }
     return $reflection->newInstance($request, $response, $controller);
 }
 public function beforeFind(Event $event, Query $query, ArrayObject $options, $primary)
 {
     if (!array_key_exists('getRelated', $options) || !$options['getRelated']) {
         //Jen pokud se mají related stahovat
         return true;
     }
     $attachedTables = $this->_InRelatedIndexBehavior->getTablesWithBehaviorNames();
     /** @var \Cake\ORM\Table $attachedTable */
     foreach ($attachedTables as $tableName) {
         $modelName = Inflector::camelize($tableName);
         $query->contain(['Related' . $modelName => []]);
     }
     $query->formatResults(function ($results) {
         return $results->map(function ($row) {
             $temp = $row->toArray();
             $related = [];
             foreach ($temp as $key => $item) {
                 if (preg_match('/related-.*/', $key)) {
                     foreach ($row->{$key} as $id => $similar) {
                         $table_name = explode('-', $key);
                         $row->{$key}[$id]->table_name = end($table_name);
                     }
                     $related = array_merge($related, $row->{$key});
                     unset($row->{$key});
                 }
             }
             $row->related = $related;
             return $row;
         });
     });
     return true;
 }
Esempio n. 12
0
 /**
  * Builds asset file path based on the provided $url.
  *
  * @param string $url Asset URL
  * @return string|void Absolute path for asset file
  */
 protected function _getAssetFile($url)
 {
     $parts = explode('/', $url);
     $pluginPart = [];
     $plugin = false;
     for ($i = 0; $i < 2; $i++) {
         if (!isset($parts[$i])) {
             break;
         }
         $pluginPart[] = Inflector::camelize($parts[$i]);
         $possiblePlugin = implode('/', $pluginPart);
         if ($possiblePlugin && Plugin::loaded($possiblePlugin)) {
             $plugin = $possiblePlugin;
             $parts = array_slice($parts, $i + 1);
             break;
         }
     }
     $isAssetRequest = isset($parts[0]) && $parts[0] === 'ASSETS';
     if ($isAssetRequest && Configure::read('debug')) {
         $parts = array_slice($parts, 1);
     } else {
         $isAssetRequest = false;
     }
     if ($plugin && Plugin::loaded($plugin)) {
         return $this->_getPluginAsset($plugin, $parts, $isAssetRequest);
     } else {
         return $this->_getAppAsset($parts, $isAssetRequest);
     }
 }
Esempio n. 13
0
 /**
  * Get the action path for a given request. Primarily used by authorize objects
  * that need to get information about the plugin, controller, and action being invoked.
  *
  * @param \Cake\Network\Request $request The request a path is needed for.
  * @param string $path Path
  * @return string The action path for the given request.
  */
 public function action(Request $request, $path = '/:plugin/:prefix/:controller/:action')
 {
     $plugin = empty($request['plugin']) ? null : preg_replace('/\\//', '\\', Inflector::camelize($request['plugin'])) . '/';
     $prefix = empty($request['prefix']) ? null : Inflector::camelize($request['prefix']) . '/';
     $path = str_replace([':controller', ':action', ':plugin/', ':prefix/'], [Inflector::camelize($request['controller']), $request['action'], $plugin, $prefix], $this->_config['actionPath'] . $path);
     $path = str_replace('//', '/', $path);
     return trim($path, '/');
 }
Esempio n. 14
0
 /**
  * Gets an ACO path for current request.
  *
  * @param \Cake\Network\Request $request Request instance
  * @param string $path Pattern
  * @return string
  */
 public function requestPath(Request $request, $path = '/:plugin/:prefix/:controller/:action')
 {
     $plugin = empty($request['plugin']) ? null : Inflector::camelize($request['plugin']) . '/';
     $prefix = empty($request->params['prefix']) ? '' : Inflector::camelize($request->params['prefix']) . '/';
     $path = str_replace([':controller', ':action', ':plugin/', ':prefix/'], [Inflector::camelize($request['controller']), $request['action'], $plugin, $prefix], $path);
     $path = str_replace('//', '/', $path);
     return trim($path, '/');
 }
 public function loader()
 {
     $this->autoRender = false;
     $model = $this->request->query['model'];
     $field_name = $this->request->query['field_name'];
     //Entityに接続して設定値を取得
     $this->__baseModel = TableRegistry::get($model);
     $entity = $this->__baseModel->newEntity();
     $contentsFileConfig = $entity->contentsFileConfig;
     if (!empty($this->request->query['tmp_file_name'])) {
         $filename = $this->request->query['tmp_file_name'];
         $filepath = $contentsFileConfig['fields'][$field_name]['cacheTempDir'] . $filename;
     } elseif (!empty($this->request->query['model_id'])) {
         //表示条件をチェックする
         $check_method_name = 'contentsFileCheck' . Inflector::camelize($field_name);
         if (method_exists($this->__baseModel, $check_method_name)) {
             //エラーなどの処理はTableに任せる
             $this->__baseModel->{$check_method_name}($this->request->query['model_id']);
         }
         //attachementからデータを取得
         $this->__attachmentModel = TableRegistry::get('Attachments');
         $attachmentData = $this->__attachmentModel->find('all')->where(['model' => $this->request->query['model']])->where(['model_id' => $this->request->query['model_id']])->where(['field_name' => $this->request->query['field_name']])->first();
         if (empty($attachmentData)) {
             //404
         }
         $filename = $attachmentData->file_name;
         $filepath = $contentsFileConfig['fields'][$field_name]['filePath'] . $attachmentData->model . '/' . $attachmentData->model_id . '/' . $attachmentData->field_name;
         //通常のセットの時のみresize設定があれば見る
         if (!empty($this->request->query['resize'])) {
             $filepath = $this->__resizeSet($filepath, $this->request->query['resize']);
         }
     }
     $file_ext = null;
     if (preg_match('/\\.([^\\.]*)$/', $filename, $ext)) {
         if ($ext[1]) {
             $file_ext = strtolower($ext[1]);
         }
     }
     $file = $filepath;
     header('Content-Length: ' . filesize($file));
     if (!empty($file_ext)) {
         $fileContentType = $this->getFileType($file_ext);
         header('Content-Type: ' . $fileContentType);
     } else {
         $fileContentType = $this->getMimeType($file);
         header('Content-Type: ' . $fileContentType);
     }
     if (strstr(env('HTTP_USER_AGENT'), 'MSIE') || strstr(env('HTTP_USER_AGENT'), 'Trident')) {
         $filename = mb_convert_encoding($filename, "SJIS", "UTF-8");
         header('Content-Disposition: filename="' . $filename . '"');
     } else {
         header('Content-Disposition: filename="' . $filename . '"');
     }
     @ob_end_clean();
     // clean
     readfile($file);
 }
 protected function _camelizePlugin($plugin)
 {
     $plugin = str_replace('-', '_', $plugin);
     if (strpos($plugin, '/') === false) {
         return Inflector::camelize($plugin);
     }
     list($vendor, $plugin) = explode('/', $plugin, 2);
     return Inflector::camelize($vendor) . '/' . Inflector::camelize($plugin);
 }
 /**
  * Mutator for the type value.
  *
  * @param string|null $type Type value.
  * @return string
  */
 public function setType($type = null)
 {
     if (!empty($type)) {
         $this->config('type', Inflector::camelize($type));
     } else {
         $type = $this->_trimClassName(get_class($this->_table));
         $this->config('type', $type);
     }
 }
 /**
  * Get csv file's last modified time.
  *
  * @param  string $tableName target table name
  * @return string
  */
 protected function _getLastModifiedTime($tableName)
 {
     $tableName = Inflector::camelize($tableName);
     $pathFinder = new MigrationPathFinder();
     $path = $pathFinder->find($tableName);
     // Unit time stamp to YYYYMMDDhhmmss
     $result = date('YmdHis', filemtime($path));
     return $result;
 }
Esempio n. 19
0
 /**
  * Execute method
  *
  * @return void
  */
 public function main($name = null)
 {
     parent::main();
     if (empty($name)) {
         return $this->error('You must provide a name to bake a ' . $this->name());
     }
     $name = Inflector::camelize($name);
     $this->bake($name);
     $this->bakeTest($name);
 }
Esempio n. 20
0
 /**
  * Social login link
  *
  * @param string $name name
  * @param array $options options
  * @return string
  */
 public function socialLogin($name, $options = [])
 {
     if (empty($options['label'])) {
         $options['label'] = __d('CakeDC/Users', 'Sign in with');
     }
     $icon = $this->Html->tag('i', '', ['class' => __d('CakeDC/Users', 'fa fa-{0}', strtolower($name))]);
     $providerTitle = __d('CakeDC/Users', '{0} {1}', Hash::get($options, 'label'), Inflector::camelize($name));
     $providerClass = __d('CakeDC/Users', 'btn btn-social btn-{0} ' . Hash::get($options, 'class') ?: '', strtolower($name));
     return $this->Html->link($icon . $providerTitle, "/auth/{$name}", ['escape' => false, 'class' => $providerClass]);
 }
Esempio n. 21
0
 /**
  * Camelize all index keys in the first level.
  *
  * Passed :
  * $array = [
  * 		'Index key' => 1,
  * 		'key-index' => 2
  * ];
  *
  * Return :
  * $array = [
  * 		'indexKey' => 1,
  * 		'keyIndex' => 2
  * ];
  *
  * @param array $array The array to be camelized.
  *
  * @return bool|array
  */
 public static function camelizeIndex($array)
 {
     if (!is_array($array)) {
         return false;
     }
     $array = array_combine(array_map(function ($key) {
         return lcfirst(Inflector::camelize($key));
     }, array_keys($array)), array_values($array));
     return $array;
 }
Esempio n. 22
0
 public function buildRules(Event $event, RulesChecker $rules)
 {
     if (empty($this->_table->transitions)) {
         return $rules;
     }
     foreach ($this->_table->transitions as $field => $transitions) {
         $ruleName = 'isValidStatefulEvent' . Inflector::camelize($field);
         $rules->add([$this, $ruleName], $ruleName, ['errorField' => $field, 'message' => __d('cake', 'This transition is invalid')]);
     }
     return $rules;
 }
Esempio n. 23
0
 /**
  * Used for generating formatted properties such as component and helper arrays
  *
  * @param string $name the name of the property
  * @param array $value the array of values
  * @param array $options extra options to be passed to the element
  * @return string
  */
 public function arrayProperty($name, array $value = [], array $options = [])
 {
     if (!$value) {
         return '';
     }
     foreach ($value as &$val) {
         $val = Inflector::camelize($val);
     }
     $options += ['name' => $name, 'value' => $value];
     return $this->_View->element('array_property', $options);
 }
 /**
  * Method that generates association naming based on passed parameters.
  *
  * @param  string $module     module name
  * @param  string $foreignKey foreign key name
  * @return string
  */
 public static function createAssociationName($module, $foreignKey = '')
 {
     list($plugin, $model) = pluginSplit($module);
     if ('' !== $foreignKey) {
         $foreignKey = Inflector::camelize($foreignKey);
     }
     $pos = strpos($plugin, '/');
     if ($pos) {
         $plugin = substr($plugin, $pos + 1);
     }
     return $foreignKey . $plugin . $model;
 }
Esempio n. 25
0
 /**
  * Returns a class name for the migration class
  *
  * If the name is invalid, the task will exit
  *
  * @param string $name Name for the generated migration
  * @return string name of the migration file
  */
 protected function getMigrationName($name = null)
 {
     if (empty($name)) {
         return $this->error('Choose a migration name to bake in CamelCase format');
     }
     $name = $this->_getName($name);
     $name = Inflector::camelize($name);
     if (!preg_match('/^[A-Z]{1}[a-zA-Z0-9]+$/', $name)) {
         return $this->error('The className is not correct. The className can only contain "A-Z" and "0-9".');
     }
     return $name;
 }
 /**
  * Method that renders related field's value.
  * @param  mixed  $table   name or instance of the Table
  * @param  string $field   field name
  * @param  string $data    field data
  * @param  array  $options field options
  * @return string
  */
 public function renderValue($table, $field, $data, array $options = [])
 {
     // load AppView
     $cakeView = new AppView();
     // get related table name
     $relatedName = $this->_getRelatedName($options['fieldDefinitions']['type']);
     // get related table's displayField value
     $displayFieldValue = $this->_getDisplayFieldValueByPrimaryKey(Inflector::camelize($relatedName), $data);
     // generate related record html link
     $result = $cakeView->Html->link(h($displayFieldValue), ['controller' => $relatedName, 'action' => static::LINK_ACTION, $data]);
     return $result;
 }
 /**
  * Data provider for the template. Overridden to include records if needed.
  *
  * @return array
  */
 public function templateData()
 {
     $templateData = parent::templateData();
     if (!empty($this->params['records'])) {
         $modelName = Inflector::camelize($templateData['table']);
         $data = $this->SeedGenerate->getRecordsFromTable($modelName, $templateData['table'])->toArray();
         if (!empty($data)) {
             $templateData['records'] = $this->stringifyRecords($data);
             #debug($templateData);exit;
         }
     }
     return $templateData;
 }
 /**
  * Main Action
  *
  * @return void
  */
 public function main()
 {
     if (count($this->args) < 2) {
         return $this->error('Please pass the controller and action name.');
     }
     $controllerName = Inflector::camelize($this->args[0]);
     $actionName = Inflector::camelize($this->args[1]);
     $this->plugin = isset($this->params['plugin']) ? $this->params['plugin'] : null;
     $this->BakeTemplate->set('controllerName', $controllerName);
     $this->BakeTemplate->set('actionName', $actionName);
     $content = $this->BakeTemplate->generate('FrontendBridge.webroot/js_controller');
     $this->bake($controllerName, $actionName, $content);
 }
Esempio n. 29
0
 /**
  * Takes a list of actions in the current controller for which authentication is not required, or
  * no parameters to allow all actions.
  *
  * You can use allow with either an array or a simple string.
  *
  * `$this->Auth->allow('view');`
  * `$this->Auth->allow(['edit', 'add']);`
  * `$this->Auth->allow();` to allow all actions
  *
  * @param string|array $actions Controller action name or array of actions.
  *
  * @return void
  */
 public function allow($actions = null)
 {
     if ($actions === null) {
         $controller = $this->_registry->getController();
         $this->allowedActions = get_class_methods($controller);
         return;
     }
     $controller = Inflector::camelize($this->request['controller']);
     $action = Inflector::underscore($this->request['action']);
     if (!$this->session->read('Auth.User') || isset($this->config('allowedActionsForBanned')[$controller]) && in_array($action, array_map('strtolower', $this->config('allowedActionsForBanned')[$controller]))) {
         $this->allowedActions = array_merge($this->allowedActions, (array) $actions);
     }
 }
Esempio n. 30
0
 /**
  * Parses a string URL into an array. If it matches, it will convert the prefix, controller and
  * plugin keys to their camelized form
  *
  * @param string $url The URL to parse
  * @return mixed false on failure, or an array of request parameters
  */
 public function parse($url)
 {
     $params = parent::parse($url);
     if (!$params) {
         return false;
     }
     if (!empty($params['controller'])) {
         $params['controller'] = Inflector::camelize($params['controller']);
     }
     if (!empty($params['plugin'])) {
         $params['plugin'] = Inflector::camelize($params['plugin']);
     }
     return $params;
 }