Skip to content
Extraits de code Groupes Projets
Segment.php 2,89 ko
Newer Older
  • Learn to ignore specific revisions
  • <?php
    /**
     * Piwik - Open source web analytics
     *
     * @link http://piwik.org
     * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
     *
     */
    namespace Piwik\Plugin;
    
    /**
     * @api
    
        const TYPE_DIMENSION = 'dimension';
        const TYPE_METRIC = 'metric';
    
    
        private $type;
        private $category;
        private $name;
        private $segment;
        private $sqlSegment;
        private $sqlFilter;
        private $sqlFilterValue;
        private $acceptValues;
    
    
        public function __construct()
        {
            $this->init();
        }
    
        protected function init()
        {
    
        }
    
        /**
    
        public function setAcceptedValues($acceptValues)
    
         */
        public function setCategory($category)
        {
            $this->category = $category;
        }
    
        /**
    
         */
        public function setName($name)
        {
            $this->name = $name;
        }
    
        /**
    
         */
        public function setSegment($segment)
        {
            $this->segment = $segment;
        }
    
        /**
    
         */
        public function setSqlFilter($sqlFilter)
        {
            $this->sqlFilter = $sqlFilter;
        }
    
        /**
    
         */
        public function setSqlFilterValue($sqlFilterValue)
        {
            $this->sqlFilterValue = $sqlFilterValue;
        }
    
        /**
    
         */
        public function setSqlSegment($sqlSegment)
        {
            $this->sqlSegment = $sqlSegment;
        }
    
    
        /**
         * @return string
         */
        public function getSqlSegment()
        {
            return $this->sqlSegment;
        }
    
    
         */
        public function setType($type)
        {
            $this->type = $type;
        }
    
    
        /**
         * @return string
         */
        public function getType()
        {
            return $this->type;
        }
    
    
        /**
         * @param bool $permission
         */
        public function setPermission($permission)
        {
            $this->permission = $permission;
        }
    
    
        public function toArray()
        {
            $segment = array(
                'type'       => $this->type,
                'category'   => $this->category,
                'name'       => $this->name,
                'segment'    => $this->segment,
                'sqlSegment' => $this->sqlSegment,
            );
    
            if (!empty($this->sqlFilter)) {
                $segment['sqlFilter'] = $this->sqlFilter;
            }
    
            if (!empty($this->sqlFilterValue)) {
                $segment['sqlFilterValue'] = $this->sqlFilterValue;
            }
    
            if (!empty($this->acceptValues)) {
                $segment['acceptedValues'] = $this->acceptValues;
            }
    
    
            if (isset($this->permission)) {
                $segment['permission'] = $this->permission;
            }