コード例 #1
0
ファイル: Blog.php プロジェクト: cakemanager/cakeadmin-cms
 protected function _getPath()
 {
     if (array_key_exists('id', $this->_properties)) {
         return PathManager::instance()->getPath('blogs', $this->_properties['id']);
     }
     return null;
 }
コード例 #2
0
 /**
  * beforeSave event
  *
  * @param \Cake\Event\Event $event Event.
  * @param \Cake\ORM\Entity $entity Entity.
  * @param array $options Options.
  * @return void
  */
 public function beforeSave($event, $entity, $options)
 {
     PathManager::instance()->removeRoutes('pages');
 }
コード例 #3
0
 * @link          http://cakemanager.org CakeManager Project
 * @since         1.0
 * @license       http://www.opensource.org/licenses/mit-license.php MIT License
 */
use Cake\Core\Configure;
use Settings\Core\Setting;
use Cake\ORM\TableRegistry;
use Cake\Cache\Cache;
use Cms\Utility\PathManager;
Configure::write('Settings.Prefixes.CMS', 'Cake CMS');
Setting::register('CMS.Pages', true, ['type' => 'checkbox']);
Setting::register('CMS.Blogs', true, ['type' => 'checkbox']);
Setting::register('CMS.Index', false, ['type' => 'select', 'options' => function () {
    return [false => 'None'] + TableRegistry::get('Cms.Pages')->find('list')->toArray();
}]);
Setting::register('CMS.BlogsUrl', '/:category_slug/:blog_slug');
if (Setting::read('CMS.Pages')) {
    Configure::write('CA.Models.pages', 'Cms.Pages');
    PathManager::instance()->register('pages', 'Cms.Pages');
}
if (Setting::read('CMS.Blogs')) {
    Configure::write('CA.Models.categories', 'Cms.Categories');
    Configure::write('CA.Models.blogs', 'Cms.Blogs');
    PathManager::instance()->register('blogs', 'Cms.Blogs');
    PathManager::instance()->register('categories', 'Cms.Categories');
}
# Notification Templates
Configure::write('Notifier.templates.blog_post', ['title' => 'A new blog has been posted', 'body' => 'The blog :title has been posted by :creator']);
# AdminBar
Configure::write('AdminBar.edit_blog', ['on' => ['plugin' => 'Cms', 'controller' => 'Blogs', 'action' => 'view'], 'label' => 'Edit Blog', 'url' => ['prefix' => 'admin', 'plugin' => 'CakeAdmin', 'controller' => 'PostTypes', 'action' => 'edit', ':pass.0', 'type' => 'blogs']]);
Configure::write('AdminBar.read_blog', ['on' => ['prefix' => 'admin', 'plugin' => 'CakeAdmin', 'controller' => 'PostTypes', 'action' => ['edit', 'view'], 'type' => 'blogs'], 'label' => 'Read Blog', 'url' => ['prefix' => false, 'plugin' => 'Cms', 'controller' => 'Blogs', 'action' => 'view', ':pass.1']]);
コード例 #4
0
 /**
  * afterSave event
  *
  * @param \Cake\Event\Event $event Event.
  * @param \Cake\ORM\Entity $entity Entity.
  * @param array $options Options.
  * @return void
  */
 public function afterSave($event, $entity, $options)
 {
     PathManager::instance()->buildRoutes('blogs');
     NotificationManager::instance()->notify(['users' => [1], 'template' => 'blog_post', 'vars' => ['title' => $entity->title, 'creator' => $entity->created_by]]);
 }
コード例 #5
0
 public function getUrl($type, $id)
 {
     return PathManager::instance()->getPath($type, $id);
 }