Overview

Namespaces

  • Charcoal
    • Admin
      • Widget
        • Cms
    • Cms
      • Config
      • Mixin
        • Traits
      • Route
      • Section
      • Service
        • Loader
        • Manager
      • ServiceProvider
      • Support
        • Helpers
        • Interfaces
        • Traits
    • Property

Classes

  • Charcoal\Admin\Widget\Cms\HierarchicalSectionTableWidget
  • Charcoal\Admin\Widget\Cms\SectionTableWidget
  • Charcoal\Cms\AbstractDocument
  • Charcoal\Cms\AbstractEvent
  • Charcoal\Cms\AbstractFaq
  • Charcoal\Cms\AbstractImage
  • Charcoal\Cms\AbstractNews
  • Charcoal\Cms\AbstractSection
  • Charcoal\Cms\AbstractText
  • Charcoal\Cms\AbstractVideo
  • Charcoal\Cms\Config
  • Charcoal\Cms\Config\CmsConfig
  • Charcoal\Cms\Config\EventConfig
  • Charcoal\Cms\Config\NewsConfig
  • Charcoal\Cms\Config\SectionConfig
  • Charcoal\Cms\Document
  • Charcoal\Cms\DocumentCategory
  • Charcoal\Cms\EmptySection
  • Charcoal\Cms\Event
  • Charcoal\Cms\EventCategory
  • Charcoal\Cms\ExternalSection
  • Charcoal\Cms\Faq
  • Charcoal\Cms\FaqCategory
  • Charcoal\Cms\Image
  • Charcoal\Cms\ImageCategory
  • Charcoal\Cms\News
  • Charcoal\Cms\NewsCategory
  • Charcoal\Cms\Route\EventRoute
  • Charcoal\Cms\Route\GenericRoute
  • Charcoal\Cms\Route\NewsRoute
  • Charcoal\Cms\Route\SectionRoute
  • Charcoal\Cms\Section
  • Charcoal\Cms\Section\BlocksSection
  • Charcoal\Cms\Section\ContentSection
  • Charcoal\Cms\Service\Loader\AbstractLoader
  • Charcoal\Cms\Service\Loader\EventLoader
  • Charcoal\Cms\Service\Loader\NewsLoader
  • Charcoal\Cms\Service\Loader\SectionLoader
  • Charcoal\Cms\Service\Manager\AbstractManager
  • Charcoal\Cms\Service\Manager\EventManager
  • Charcoal\Cms\Service\Manager\NewsManager
  • Charcoal\Cms\ServiceProvider\CmsServiceProvider
  • Charcoal\Cms\Support\Helpers\DateHelper
  • Charcoal\Cms\Tag
  • Charcoal\Cms\Text
  • Charcoal\Cms\TextCategory
  • Charcoal\Cms\Video
  • Charcoal\Cms\VideoCategory
  • Charcoal\Property\TemplateOptionsProperty
  • Charcoal\Property\TemplateProperty

Interfaces

  • Charcoal\Cms\DocumentInterface
  • Charcoal\Cms\EventInterface
  • Charcoal\Cms\FaqInterface
  • Charcoal\Cms\ImageInterface
  • Charcoal\Cms\MetatagInterface
  • Charcoal\Cms\Mixin\HasContentBlocksInterface
  • Charcoal\Cms\NewsInterface
  • Charcoal\Cms\SearchableInterface
  • Charcoal\Cms\SectionInterface
  • Charcoal\Cms\Support\Interfaces\EventManagerAwareInterface
  • Charcoal\Cms\Support\Interfaces\NewsManagerAwareInterface
  • Charcoal\Cms\Support\Interfaces\SectionLoaderAwareInterface
  • Charcoal\Cms\TemplateableInterface
  • Charcoal\Cms\TextInterface
  • Charcoal\Cms\VideoInterface

Traits

  • Charcoal\Admin\Widget\Cms\SectionTableTrait
  • Charcoal\Cms\MetatagTrait
  • Charcoal\Cms\Mixin\Traits\HasContentBlocksTrait
  • Charcoal\Cms\SearchableTrait
  • Charcoal\Cms\Support\Traits\DateHelperAwareTrait
  • Charcoal\Cms\Support\Traits\EventManagerAwareTrait
  • Charcoal\Cms\Support\Traits\NewsManagerAwareTrait
  • Charcoal\Cms\Support\Traits\SectionLoaderAwareTrait
  • Charcoal\Cms\TemplateableTrait
  • Overview
  • Namespace
  • Class
  1: <?php
  2: 
  3: namespace Charcoal\Cms\Service\Manager;
  4: 
  5: // dependency from charcoal-factory
  6: use Charcoal\Factory\FactoryInterface;
  7: 
  8: // dependency from charcoal-core
  9: use Charcoal\Loader\CollectionLoader;
 10: 
 11: // Psr-7 dependencies
 12: use RuntimeException;
 13: use Exception;
 14: 
 15: use \Charcoal\Translator\TranslatorAwareTrait;
 16: 
 17: /**
 18:  * Abstract Manager
 19:  */
 20: class AbstractManager
 21: {
 22:     use TranslatorAwareTrait;
 23: 
 24:     /**
 25:      * Store the factory instance for the current class.
 26:      *
 27:      * @var FactoryInterface
 28:      */
 29:     protected $modelFactory;
 30: 
 31:     /**
 32:      * Store the collection loader for the current class.
 33:      *
 34:      * @var CollectionLoader
 35:      */
 36:     protected $collectionLoader;
 37: 
 38:     /**
 39:      * @var object $adminConfig The admin config object model.
 40:      */
 41:     protected $adminConfig;
 42: 
 43:     /**
 44:      * NewsManager constructor.
 45:      * @param array $data The Data.
 46:      * @throws Exception When $data index is not set.
 47:      */
 48:     public function __construct(array $data)
 49:     {
 50:         if (!isset($data['factory'])) {
 51:             throw new Exception(sprintf(
 52:                 'Model Factory must be defined in the %s constructor.',
 53:                 get_called_class()
 54:             ));
 55:         }
 56:         if (!isset($data['loader'])) {
 57:             throw new Exception(sprintf(
 58:                 'CollectionLoader must be defined in the %s constructor.',
 59:                 get_called_class()
 60:             ));
 61:         }
 62:         if (!isset($data['cms/config'])) {
 63:             throw new Exception('You must define a global config object in your cms.json config file. (config_obj)');
 64:         }
 65: 
 66:         if (isset($data['translator'])) {
 67:             $this->setTranslator($data['translator']);
 68:         }
 69: 
 70:         $this->setModelFactory($data['factory']);
 71:         $this->setCollectionLoader($data['loader']);
 72:         $this->setAdminConfig($data['cms/config']);
 73:     }
 74: 
 75:     /**
 76:      * Set an object model factory.
 77:      *
 78:      * @param FactoryInterface $factory The model factory, to create objects.
 79:      * @return self
 80:      */
 81:     protected function setModelFactory(FactoryInterface $factory)
 82:     {
 83:         $this->modelFactory = $factory;
 84: 
 85:         return $this;
 86:     }
 87: 
 88:     /**
 89:      * Retrieve the object model factory.
 90:      *
 91:      * @throws RuntimeException If the model factory was not previously set.
 92:      * @return FactoryInterface
 93:      */
 94:     public function modelFactory()
 95:     {
 96:         if (!isset($this->modelFactory)) {
 97:             throw new RuntimeException(
 98:                 sprintf('Model Factory is not defined for "%s"', get_class($this))
 99:             );
100:         }
101: 
102:         return $this->modelFactory;
103:     }
104: 
105:     /**
106:      * Set a model collection loader.
107:      *
108:      * @param CollectionLoader $loader The collection loader.
109:      * @return self
110:      */
111:     protected function setCollectionLoader(CollectionLoader $loader)
112:     {
113:         $this->collectionLoader = $loader;
114: 
115:         return $this;
116:     }
117: 
118:     /**
119:      * Retrieve the model collection loader.
120:      *
121:      * @throws RuntimeException If the collection loader was not previously set.
122:      * @return CollectionLoader
123:      */
124:     public function collectionLoader()
125:     {
126:         if (!isset($this->collectionLoader)) {
127:             throw new RuntimeException(
128:                 sprintf('Collection Loader is not defined for "%s"', get_class($this))
129:             );
130:         }
131: 
132:         return $this->collectionLoader;
133:     }
134: 
135:     /**
136:      * @param mixed $adminConfig The admin configuration.
137:      * @return self
138:      */
139:     public function setAdminConfig($adminConfig)
140:     {
141:         $this->adminConfig = $adminConfig;
142: 
143:         return $this;
144:     }
145: 
146:     /**
147:      * @return mixed
148:      */
149:     public function adminConfig()
150:     {
151:         return $this->adminConfig;
152:     }
153: }
154: 
API documentation generated by ApiGen