"Fossies" - the Fresh Open Source Software Archive

Member "papayacms-core-6.12.5/src/system/Papaya/Plugin/Editable/Options/Aggregation.php" (7 Jul 2020, 2334 Bytes) of package /linux/www/papayacms-core-6.12.5.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) PHP source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "Aggregation.php" see the Fossies "Dox" file reference documentation.

    1 <?php
    2 /**
    3  * papaya CMS
    4  *
    5  * @copyright 2000-2018 by papayaCMS project - All rights reserved.
    6  * @link http://www.papaya-cms.com/
    7  * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU General Public License, version 2
    8  *
    9  *  You can redistribute and/or modify this script under the terms of the GNU General Public
   10  *  License (GPL) version 2, provided that the copyright and license notes, including these
   11  *  lines, remain unmodified. papaya is distributed in the hope that it will be useful, but
   12  *  WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
   13  *  FOR A PARTICULAR PURPOSE.
   14  */
   15 namespace Papaya\Plugin\Editable\Options;
   16 
   17 use Papaya\Plugin;
   18 
   19 /**
   20  * This a standard implementation for editable plugin options. It
   21  * makes implements the \Papaya\Plugin\Editable interface and
   22  * expects an implementation of the abstract method "createOptionsEditor".
   23  *
   24  * The method needs to return a \Papaya\Plugin\Editor instance.
   25  *
   26  * @package Papaya-Library
   27  * @subpackage Plugins
   28  */
   29 trait Aggregation {
   30   /**
   31    * @var \Papaya\Plugin\Editable\Content
   32    */
   33   private $_options;
   34 
   35   /**
   36    * The content is an {@see ArrayObject} child class containing the stored data.
   37    *
   38    * @param Plugin\Editable\Options $options
   39    * @return Plugin\Editable\Options
   40    */
   41   public function options(Plugin\Editable\Options $options = NULL) {
   42     if (NULL !== $options) {
   43       $this->_options = $options;
   44     } elseif (NULL === $this->_options) {
   45       $this->_options = new Plugin\Editable\Options(
   46         new Plugin\Options($this->getPluginGuid())
   47       );
   48       $this->_options->callbacks()->onCreateEditor = function(
   49         /** @noinspection PhpUnusedParameterInspection */
   50         $context, Plugin\Editable\Options $options
   51       ) {
   52         return $this->createOptionsEditor($options);
   53       };
   54     }
   55     return $this->_options;
   56   }
   57 
   58   /**
   59    * @param Plugin\Editable\Options $options
   60    *
   61    * @return \Papaya\Plugin\Editor
   62    */
   63   abstract public function createOptionsEditor(Plugin\Editable\Options $options);
   64 
   65   /**
   66    * The plugin guid will be set as a public property by the plugin manager.
   67    *
   68    * @return string
   69    */
   70   public function getPluginGuid() {
   71     if (isset($this->guid)) {
   72       return $this->guid;
   73     }
   74     throw new \LogicException('No plugin guid found.');
   75   }
   76 }