/**
  * Transform a PSR7 request into a CakePHP one.
  *
  * @param \Psr\Http\Message\ServerRequestInterface $request The PSR7 request.
  * @return \Cake\Network\Request The transformed request.
  */
 public static function toCake(PsrRequest $request)
 {
     $post = $request->getParsedBody();
     $server = $request->getServerParams();
     $files = static::getFiles($request);
     if (!empty($files)) {
         $post = Hash::merge($post, $files);
     }
     return new CakeRequest(['query' => $request->getQueryParams(), 'post' => $post, 'cookies' => $request->getCookieParams(), 'environment' => $server, 'params' => static::getParams($request), 'url' => $request->getUri()->getPath(), 'base' => $request->getAttribute('base', ''), 'webroot' => $request->getAttribute('webroot', '/')]);
 }
 /**
  * @param int $id
  * @param array $options
  *
  * @return array
  */
 public function neighbors($id, array $options = [])
 {
     if (!$id) {
         throw new InvalidArgumentException("The 'id' key is required for find('neighbors')");
     }
     $sortField = $this->_table->hasField('created') ? 'created' : $this->_table->primaryKey();
     $defaults = ['sortField' => $this->_table->alias() . '.' . $sortField];
     $options += $defaults;
     $normalDirection = !empty($options['reverse']) ? false : true;
     $sortDirWord = $normalDirection ? ['ASC', 'DESC'] : ['DESC', 'ASC'];
     $sortDirSymb = $normalDirection ? ['>=', '<='] : ['<=', '>='];
     if (empty($options['value'])) {
         $data = $this->_table->find('all', ['conditions' => [$this->_table->primaryKey() => $id]])->first();
         list($model, $sortField) = pluginSplit($options['sortField']);
         $options['value'] = $data[$sortField];
     }
     $return = [];
     $findOptions = [];
     if (isset($options['contain'])) {
         $findOptions['contain'] = $options['contain'];
     }
     if (!empty($options['fields'])) {
         $findOptions['fields'] = $options['fields'];
     }
     $findOptions['conditions'][$this->_table->alias() . '.' . $this->_table->primaryKey() . ' !='] = $id;
     $prevOptions = $findOptions;
     $prevOptions['conditions'] = Hash::merge($prevOptions['conditions'], [$options['sortField'] . ' ' . $sortDirSymb[1] => $options['value']]);
     $prevOptions['order'] = [$options['sortField'] => $sortDirWord[1]];
     $return['prev'] = $this->_table->find('all', $prevOptions)->first();
     $nextOptions = $findOptions;
     $nextOptions['conditions'] = Hash::merge($nextOptions['conditions'], [$options['sortField'] . ' ' . $sortDirSymb[0] => $options['value']]);
     $nextOptions['order'] = [$options['sortField'] => $sortDirWord[0]];
     $return['next'] = $this->_table->find('all', $nextOptions)->first();
     return $return;
 }
 public function loadDataCsv($fileName, $column_list, $delimiter = ",", $array_encoding = 'utf8', $import_encoding = 'sjis-win')
 {
     //保存をするのでモデルを読み込み
     try {
         $data = array();
         $csvData = array();
         $file = fopen($fileName, "r");
         while ($data = $this->fgetcsv_reg($file, 65536, $delimiter)) {
             //CSVファイルを","区切りで配列に
             mb_convert_variables($array_encoding, $import_encoding, $data);
             $csvData[] = $data;
         }
         $i = 0;
         foreach ($csvData as $line) {
             $this_data = array();
             foreach ($column_list as $k => $v) {
                 if (isset($line[$k])) {
                     //先頭と末尾の"を削除
                     $b = $line[$k];
                     //カラムの数だけセット
                     $this_data = Hash::merge($this_data, array($v => $b));
                 } else {
                     $this_data = Hash::merge($this_data, array($v => ''));
                 }
             }
             $data[$i] = $this_data;
             $i++;
         }
     } catch (\Exception $e) {
         return false;
     }
     return $data;
 }
 /**
  * Creates a Transport instance
  *
  * @param array $config transport-specific configuration options
  */
 public function __construct(array $config)
 {
     $config = Hash::merge(Configure::read('Notifications.transports.sms'), $config);
     parent::__construct($config);
     $keys = Configure::read('Notifications.transports.sms');
     $this->_smsClient = new \WebSmsCom_Client($keys['username'], $keys['password'], $keys['gateway']);
 }
예제 #5
0
 /**
  * Initialization hook method.
  *
  * @return void
  */
 public function initialize()
 {
     parent::initialize();
     if (Configure::read('Swagger')) {
         $this->config = Hash::merge(static::$defaultConfig, Configure::read('Swagger'));
     }
 }
예제 #6
0
 /**
  * Get format permission data.
  *
  * @param $acos
  * @param array $aros
  * @param array $options
  * @return array
  * @SuppressWarnings("unused")
  */
 public function format($acos, array $aros, array $options = [])
 {
     $options = Hash::merge(['perms' => true, 'model' => 'Roles'], $options);
     $permissions = [];
     /** @var \Acl\Model\Entity\Aco $aco */
     foreach ($acos as $aco) {
         $acoId = $aco->get('id');
         $acoAlias = $aco->get('alias');
         $path = $this->Acos->find('path', ['for' => $acoId]);
         $path = join('/', collection($path)->extract('alias')->toArray());
         $data = ['path' => $path, 'alias' => $acoAlias, 'depth' => substr_count($path, '/')];
         foreach ($aros as $key => $aroId) {
             $role = ['foreign_key' => $key, 'model' => $options['model']];
             if ($options['perms']) {
                 $isCheck = $this->check($role, $path);
                 if ($key == Role::ADMIN_ID || $isCheck) {
                     $data['roles'][$key] = 1;
                 } else {
                     $data['roles'][$key] = (int) $isCheck;
                 }
             }
             $permissions[$acoId] = new Data($data);
         }
     }
     return $permissions;
 }
예제 #7
0
 /**
  * Merge Configuration
  *
  * @param string $key Configure key
  * @param array $config New configuration to merge
  * @param return array Array of merged configurations
  */
 public static function mergeConfig($key, $config)
 {
     $values = Configure::read($key);
     $values = Hash::merge((array) $values, $config);
     Configure::write($key, $values);
     return $values;
 }
예제 #8
0
파일: NavHelper.php 프로젝트: UnionCMS/Core
 /**
  * Create and render navigation menu.
  *
  * @param array $items
  * @param string|int $key
  * @param array $options
  * @param int $level
  * @return string
  */
 public function render($key, array $items = [], array $options = [], $level = 1)
 {
     $_options = ['active' => 'active', 'type' => self::MENU_TYPE_COLLAPSE, 'menuAttr' => ['class' => 'menu', 'id' => 'level-' . $level]];
     $counter = 0;
     $out = '';
     $options = Hash::merge($_options, $options);
     $menuAttr = $options['menuAttr'];
     $type = $options['type'];
     $sorted = Hash::sort($items, '{s}.weight', 'ASC');
     foreach ($sorted as $link) {
         $child = '';
         $counter = $counter + 1;
         $title = h($link['title']);
         $liAttr = $this->_setLiAttr($counter, $link, $options);
         $linkAttr = $this->_setLinkAttr($counter, $link, $options);
         if (count($link['children']) > 0) {
             list($child, $link, $linkAttr, $title, $level) = $this->_createChild($key, $link, $level, $linkAttr, $type);
         }
         $title = $this->_createIcon($title, $link);
         $linkItem = $this->link($title, $link['url'], $linkAttr);
         $out .= $this->tag('li', $linkItem . $child, $liAttr);
         $counter++;
     }
     return $this->tag('ul', $out, $menuAttr);
 }
예제 #9
0
 /**
  * Returns a counter string for the paged result set
  *
  * ### Options
  *
  * - `model` The model to use, defaults to PaginatorHelper::defaultModel();
  * - `format` The format string you want to use, defaults to 'pages' Which generates output like '1 of 5'
  *    set to 'range' to generate output like '1 - 3 of 13'. Can also be set to a custom string, containing
  *    the following placeholders `{{page}}`, `{{pages}}`, `{{current}}`, `{{count}}`, `{{model}}`, `{{start}}`, `{{end}}` and any
  *    custom content you would like.
  *
  * @param string|array $options Options for the counter string. See #options for list of keys.
  *   If string it will be used as format.
  * @return string Counter string.
  * @link http://book.cakephp.org/3.0/en/views/helpers/paginator.html#creating-a-page-counter
  */
 public function counter($options = [])
 {
     if (is_string($options)) {
         $options = ['format' => $options];
     }
     $default = ['model' => $this->defaultModel(), 'format' => 'pages'];
     $options = \Cake\Utility\Hash::merge($default, $options);
     $paging = $this->params($options['model']);
     if (!$paging['pageCount']) {
         $paging['pageCount'] = 1;
     }
     $start = 0;
     if ($paging['count'] >= 1) {
         $start = ($paging['page'] - 1) * $paging['perPage'] + 1;
     }
     $end = $start + $paging['perPage'] - 1;
     if ($paging['count'] < $end) {
         $end = $paging['count'];
     }
     switch ($options['format']) {
         case 'range':
         case 'pages':
             $template = 'counter' . ucfirst($options['format']);
             break;
         default:
             $template = 'counterCustom';
             $this->templater()->add([$template => $options['format']]);
     }
     $map = array_map([$this->Number, 'format'], ['page' => $paging['page'], 'pages' => $paging['pageCount'], 'current' => $paging['current'], 'count' => $paging['count'], 'start' => $start, 'end' => $end]);
     $map += ['model' => strtolower(Inflector::humanize(Inflector::tableize($options['model'])))];
     return $this->templater()->format($template, $map);
 }
 /**
  * Wrap Moxiemanager's api.php in a controller action.
  *
  * @return void
  */
 public function api()
 {
     try {
         $pluginPath = Plugin::path('CkTools');
         define('MOXMAN_CLASSES', $pluginPath . 'src/Lib/moxiemanager/classes');
         define('MOXMAN_PLUGINS', $pluginPath . 'src/Lib/moxiemanager/plugins');
         define('MOXMAN_ROOT', $pluginPath . 'src/Lib/moxiemanager');
         define('MOXMAN_API_FILE', __FILE__);
         $appConfig = Configure::read('CkTools.moxiemanager');
         Configure::load('CkTools.moxiemanager');
         $moxieManagerConfig = Configure::read('moxiemanager');
         if (is_array($appConfig)) {
             $moxieManagerConfig = Hash::merge($moxieManagerConfig, $appConfig);
         }
         $GLOBALS['moxieManagerConfig'] = $moxieManagerConfig;
         require_once MOXMAN_CLASSES . '/MOXMAN.php';
         $context = \MOXMAN_Http_Context::getCurrent();
         $pluginManager = \MOXMAN::getPluginManager();
         foreach ($pluginManager->getAll() as $plugin) {
             if ($plugin instanceof \MOXMAN_Http_IHandler) {
                 $plugin->processRequest($context);
             }
         }
     } catch (Exception $e) {
         \MOXMAN_Exception::printException($e);
     }
     return $this->render(false, false);
 }
 /**
  * Send mail using Mandrill (by MailChimp)
  *
  * @param \Cake\Network\Email\Email $email Cake Email
  * @return array
  */
 public function send(Email $email)
 {
     $this->transportConfig = Hash::merge($this->transportConfig, $this->_config);
     // Initiate a new Mandrill Message parameter array
     $message = ['html' => $email->message(\Cake\Network\Email\Email::MESSAGE_HTML), 'text' => $email->message(\Cake\Network\Email\Email::MESSAGE_TEXT), 'subject' => $this->_decode($email->subject()), 'from_email' => key($email->from()), 'from_name' => current($email->from()), 'to' => [], 'headers' => ['Reply-To' => is_null(key($email->replyTo())) ? key($email->from()) : key($email->replyTo())], 'recipient_metadata' => [], 'attachments' => [], 'images' => []];
     // Merge Mandrill Parameters
     $message = array_merge($message, Hash::merge($this->defaultParameters, $email->profile()['Mandrill']));
     // Add receipients
     foreach (['to', 'cc', 'bcc'] as $type) {
         foreach ($email->{$type}() as $mail => $name) {
             $message['to'][] = ['email' => $mail, 'name' => $name, 'type' => $type];
         }
     }
     // Attachments
     $message = $this->_attachments($email, $message);
     // Create a new scoped Http Client
     $this->http = new Client(['host' => 'mandrillapp.com', 'scheme' => 'https', 'headers' => ['User-Agent' => 'CakePHP Mandrill Plugin']]);
     // Sending as a template? Then in case we find mail content, we add this as a 'template_content'.
     // In you Mandrill template, use <div mc:edit="content"></div> to get the contents of your email
     if (!is_null($message['template_name']) && $message['html']) {
         if (!isset($message['template_content']) || !is_array($message['template_content'])) {
             $message['template_content'] = [];
         }
         $message['template_content'][] = ['name' => 'content', 'content' => $message['html']];
     }
     // Are we sending a template?
     if (!is_null($message['template_name']) && !empty($message['template_content'])) {
         return $this->_sendTemplate($message, $this->transportConfig['async'], $this->transportConfig['ip_pool'], $message['send_at']);
     } else {
         return $this->_send($message, $this->transportConfig['async'], $this->transportConfig['ip_pool'], $message['send_at']);
     }
 }
예제 #12
0
 /**
  * Class Constructor
  *
  * Merges defaults with
  * - Configure::read(Meta)
  * - Helper options
  * - viewVars _meta
  * in that order (the latter trumps)
  *
  * @param array $options
  */
 public function __construct(View $View, $options = [])
 {
     parent::__construct($View, $options);
     $configureMeta = (array) Configure::read('Meta');
     if (Configure::read('Meta.robots') && is_array(Configure::read('Meta.robots'))) {
         $configureMeta['robots'] = Hash::merge($this->meta['robots'], Configure::read('Meta.robots'));
     }
     $this->meta = $configureMeta + $this->meta;
     if (!empty($options['robots']) && is_array($options['robots'])) {
         $options['robots'] = Hash::merge($this->meta['robots'], $options['robots']);
     }
     $this->meta = $options + $this->meta;
     if (!empty($this->_View->viewVars['_meta'])) {
         $viewVarsMeta = (array) $this->_View->viewVars['_meta'];
         if (!empty($viewVarsMeta['robots']) && is_array($viewVarsMeta['robots'])) {
             $viewVarsMeta['robots'] = Hash::merge($this->meta['robots'], $viewVarsMeta['robots']);
         }
         $this->meta = $viewVarsMeta + $this->meta;
     }
     if ($this->meta['charset'] === null) {
         // By default include this
         $this->meta['charset'] = true;
     }
     if ($this->meta['icon'] === null) {
         // By default include this
         $this->meta['icon'] = true;
     }
     if ($this->meta['title'] === null) {
         $this->meta['title'] = __(Inflector::humanize(Inflector::underscore($this->request->params['controller']))) . ' - ' . __(Inflector::humanize(Inflector::underscore($this->request->params['action'])));
     }
 }
 /**
  * Render an attachments area for the given entity
  *
  * @param EntityInterface $entity Entity to attach files to
  * @param array $options Override default options
  * @return string
  */
 public function attachmentsArea(EntityInterface $entity, array $options = [])
 {
     if ($this->config('includeDependencies')) {
         $this->addDependencies();
     }
     $options = Hash::merge(['label' => false, 'id' => 'fileupload-' . uniqid(), 'formFieldName' => false, 'mode' => 'full', 'style' => '', 'taggable' => false, 'isAjax' => false, 'panelHeading' => __d('attachments', 'attachments'), 'showIconColumn' => true, 'additionalButtons' => null], $options);
     return $this->_View->element('Attachments.attachments_area', compact('options', 'entity'));
 }
예제 #14
0
 /**
  * Render ajax toggle element.
  *
  * @param array|string $url
  * @param array $data
  * @param Entity|\Cake\ORM\Entity $entity
  * @return string
  */
 public function toggle($entity, $url = [], array $data = [])
 {
     if (empty($url)) {
         $url = ['action' => 'toggle', 'prefix' => $this->request->param('prefix'), 'plugin' => $this->request->param('plugin'), 'controller' => $this->request->param('controller'), (int) $entity->get('id'), (int) $entity->get('status')];
     }
     $data = Hash::merge(['url' => $url, 'entity' => $entity], $data);
     return $this->_View->element(__FUNCTION__, $data);
 }
예제 #15
0
 /**
  * Render filter element.
  *
  * @param string $model
  * @param array $fields
  * @param null|string $element
  * @param array $data
  * @return string
  */
 public function render($model, array $fields = [], $element = null, array $data = [])
 {
     if ($element === null) {
         $element = self::ELEMENT_DEFAULT;
     }
     $data = Hash::merge(['clearUrl' => [], 'model' => $model, 'formFields' => $fields], $data);
     return $this->_View->element($element, $data);
 }
 /**
  * Constructor
  *
  * @param \Cake\ORM\Table $table The table this behavior is attached to.
  * @param array $config The settings for this behavior.
  */
 public function __construct(Table $table, array $config = [])
 {
     $this->_defaultConfig = Hash::merge($this->_defaultConfig, (array) Configure::read('FileStorage.Behavior'));
     parent::__construct($table, $config);
     $this->_table = $table;
     if ($this->_config['validate'] === true) {
         $this->configureUploadValidation($this->_config['validator']);
     }
 }
예제 #17
0
 /**
  * Normalizes providers' configuration.
  *
  * @param array $config Array of config to normalize.
  * @return array
  * @throws \Exception
  */
 public function normalizeConfig(array $config)
 {
     $config = Hash::merge((array) Configure::read('OAuth2'), $config);
     if (empty($config['providers'])) {
         throw new MissingProviderConfigurationException();
     }
     array_walk($config['providers'], [$this, '_normalizeConfig'], $config);
     return $config;
 }
예제 #18
0
 /**
  * Generates input for parameter
  *
  * @param BaseParameter $param Form parameter.
  * @param array $options Additional input options.
  * @return array
  */
 public function input(BaseParameter $param, $options = [])
 {
     $input = $this->_defaultInput($param);
     $this->_setValue($input, $param);
     $this->_setOptions($input, $param);
     $this->_applyAutocompleteOptions($input, $param);
     $input = Hash::merge($input, $options);
     return $input;
 }
예제 #19
0
 /**
  * Parses an URL and tries to match
  *
  * @param string $url URL
  * @return array|false
  */
 public function parse($url, $method = '')
 {
     $PagesModel = TableRegistry::get('Cms.CmsPages');
     if ($pageId = $PagesModel->findPageIdBySlug($url)) {
         $url = Hash::merge($this->defaults, ['pass' => [$pageId]]);
         return $url;
     }
     return false;
 }
예제 #20
0
 /**
  * Construct the widgets and binds the default context providers
  *
  * @param \Cake\View\View $View The View this helper is being attached to.
  * @param array $config Configuration settings for the helper.
  */
 public function __construct(View $View, array $config = [])
 {
     $this->_defaultConfig += $this->_defaultConfigExt;
     $defaultConfig = (array) Configure::read('FormConfig');
     if ($defaultConfig) {
         $this->_defaultConfig = Hash::merge($this->_defaultConfig, $defaultConfig);
     }
     parent::__construct($View, $config);
 }
 /**
  * Constructor
  *
  * @param string $code 	One of Types::CODE_*, or an array containing 'code' and 'data' keys
  * @param array $data 	data to return
  */
 public function __construct($code, array $data = array())
 {
     if (is_array($code)) {
         $body = \Cake\Utility\Hash::merge(array('code' => 'success', 'data' => array()), $code);
     } else {
         $body = array('code' => $code, 'data' => $data);
     }
     $options = array('type' => 'json', 'body' => json_encode($body));
     parent::__construct($options);
 }
예제 #22
0
 /**
  * Create filepicker input
  *
  * @return string
  */
 public function picker($fieldName, array $options = [])
 {
     if (!isset($options['class'])) {
         $options['class'] = '';
     }
     $options['class'] .= ' mox-picker';
     $options = Hash::merge(['append' => $this->Html->link(__d('tinymce', 'pick_file'), '#', ['class' => 'mox-picker-btn'])], $options);
     $picker = $this->Form->input($fieldName, $options);
     return $picker;
 }
예제 #23
0
 /**
  * Construct the widgets and binds the default context providers.
  *
  * @param \Cake\View\View $View The View this helper is being attached to.
  * @param array $config Configuration settings for the helper.
  */
 public function __construct(View $View, array $config = [])
 {
     $this->_defaultConfig = ['align' => 'default', 'errorClass' => null, 'grid' => ['left' => 2, 'middle' => 6, 'right' => 4], 'templates' => $this->_templates + $this->_defaultConfig['templates']] + $this->_defaultConfig;
     if (isset($this->_defaultConfig['templateSet'])) {
         $this->_defaultConfig['templateSet'] = Hash::merge($this->_templateSet, $this->_defaultConfig['templateSet']);
     } else {
         $this->_defaultConfig['templateSet'] = $this->_templateSet;
     }
     $this->_defaultWidgets = $this->_widgets + $this->_defaultWidgets;
     parent::__construct($View, $config);
 }
예제 #24
0
 /**
  * Generate fresh filesystem documents for all entries found in the library.
  *
  * @param string $host Hostname of system serving swagger documents (without protocol)
  * @return void
  */
 public function makedocs($host)
 {
     // make same configuration as used by the API availble inside the lib
     require ROOT . DS . 'config/routes.php';
     if (Configure::read('Swagger')) {
         $this->config = Hash::merge(AppController::$defaultConfig, Configure::read('Swagger'));
     }
     $this->out('Crawl-generating swagger documents...');
     SwaggerTools::makeDocs($host);
     $this->out('Command completed successfully.');
 }
예제 #25
0
 /**
  * Get HTTP Client
  *
  * @return Client
  */
 protected function client()
 {
     if (!$this->_client) {
         $config = $this->connection()->config();
         if (!empty($this->clientConfig)) {
             $config = Hash::merge($config, $this->clientConfig);
         }
         $this->_client = new Client($config);
     }
     return $this->_client;
 }
 /**
  * The dictionary of vowels and consonants for the password generation.
  *
  * @param array $options
  * @return array
  */
 public function _passwordDictionary(array $options = [])
 {
     $defaults = ['vowels' => ['a', 'e', 'i', 'o', 'u'], 'cons' => ['b', 'c', 'd', 'g', 'h', 'j', 'k', 'l', 'm', 'n', 'p', 'r', 's', 't', 'u', 'v', 'w', 'tr', 'cr', 'br', 'fr', 'th', 'dr', 'ch', 'ph', 'wr', 'st', 'sp', 'sw', 'pr', 'sl', 'cl']];
     if (isset($options['cons'])) {
         unset($defaults['cons']);
     }
     if (isset($options['vowels'])) {
         unset($defaults['vowels']);
     }
     return Hash::merge($defaults, $options);
 }
 /**
  * Paginator Widget
  *
  * @param array $options Options
  * @return string Markup
  */
 public function numbers(array $options = [])
 {
     $options = Hash::merge(['first' => 1, 'last' => 1], $options);
     parent::templates(['ellipsis' => '<li class="disabled"><a>...</a></li>']);
     $pagination = '';
     $pagination .= parent::prev('&laquo;', ['escape' => false]);
     $pagination .= parent::numbers($options);
     $pagination .= parent::next('&raquo;', ['escape' => false]);
     $counter = parent::counter(['format' => '{{count}} Einträge']);
     $ret = sprintf('<nav><ul class="pagination">%s<li class="counter"><a>%s</a></li></ul></nav>', $pagination, $counter);
     return $ret;
 }
예제 #28
0
 /**
  * Define which fields are formated
  * @param array $options [description]
  * @return void
  */
 public function setFields($options = [])
 {
     $fields = !empty($options) ? $options : Configure::read('Contact.fields');
     $newFields = $this->_defaultFields;
     if (!empty($fields)) {
         if (!empty($fields['exclusive'])) {
             $newFields = $fields;
         } else {
             $newFields = Hash::merge($this->_defaultFields, $fields);
         }
     }
     $this->_fieldsName = $newFields;
 }
예제 #29
0
 /**
  * Renders a breadcrumb menu list.
  *
  * This methods renders an `<ol>` HTML menu using `MenuHelper` class, check this
  * class for more information about valid options.
  *
  * @param array $options Array of options for `MenuHelper::render()` method
  * @return string HTML
  * @see \Menu\View\Helper\MenuHelper::render()
  */
 public function render($options = [])
 {
     $items = $this->getStack();
     $options = Hash::merge(['breadcrumbGuessing' => false, 'class' => 'breadcrumb', 'templates' => ['root' => '<ol{{attrs}}>{{content}}</ol>'], 'formatter' => function ($entity, $info) {
         $options = [];
         if ($info['index'] === $info['total']) {
             $options['childAttrs'] = ['class' => 'active'];
             $options['templates']['link'] = '{{content}}';
         }
         return $this->Menu->formatter($entity, $info, $options);
     }], $options);
     return $this->Menu->render($items, $options);
 }
 /**
  * Creates a Notification entity
  *
  * @param string $identifier content identifier
  * @param array  $data view vars
  * 					To pass in attachments, add a key named 'attachments' - this array
  * 					will be passed to Email::attachments().
  * @param bool $enqueue whether to immediately save and enqueue the notification
  * @return Notification notification entity
  * @throws \InvalidArgumentException Thrown if a non-existant content identifier is given
  */
 public function createNotification($identifier, array $data, $enqueue = false)
 {
     $data = Hash::merge(['locale' => Configure::read('locale'), 'recipient_user_id' => null, 'transport' => null, 'config' => [], 'locked' => false, 'send_tries' => 0, 'sent' => 0, 'send_after' => null, 'notification_identifier' => $identifier], $data);
     $content = TableRegistry::get('Notifications.NotificationContents')->getByIdentifier($identifier, $data['locale']);
     if (!$content) {
         throw new \InvalidArgumentException(__d('notifications', 'create_notification.invalid_identifier', $identifier));
     }
     $notification = $this->newEntity($data);
     if ($enqueue) {
         return $this->enqueue($notification);
     }
     return $notification;
 }