<?php
namespace Moto\System\Plugins; use Moto; class PluginCollection extends Moto\System\BaseCollection { protected $_items; protected function _sanitizeItems($items) { $items = parent::_sanitizeItems($items); $result = array(); foreach($items as $item) { if ($item instanceof Moto\System\Plugins\PluginItem) { $result[] = $item; } } return $result; } public function toArray($keys = null) { return array_map(function ($value) use ($keys) { if ($value instanceof Moto\System\Plugins\PluginItem) { return $value->toArray($keys); } return $value; }, $this->_items); } public function getInstalled() { return $this->filter(function($plugin) { return $plugin->isInstalled(); }); } public function getNotInstalled() { return $this->filter(function($plugin) { return !$plugin->isInstalled(); }); } public function getActivated() { return $this->filter(function($plugin) { return $plugin->isActivated(); }); } public function getNotActivated() { return $this->filter(function($plugin) { return !$plugin->isActivated(); }); } } 