芝麻web文件管理V1.00
编辑当前文件:/home/mgatv524/public_html/mctv/lib/Factory/UserOptionFactory.php
. */ namespace Xibo\Factory; use Xibo\Entity\UserOption; use Xibo\Helper\SanitizerService; use Xibo\Service\LogServiceInterface; use Xibo\Storage\StorageServiceInterface; /** * Class UserOptionFactory * @package Xibo\Factory */ class UserOptionFactory extends BaseFactory { /** * Construct a factory * @param StorageServiceInterface $store * @param LogServiceInterface $log * @param SanitizerService $sanitizerService */ public function __construct($store, $log, $sanitizerService) { $this->setCommonDependencies($store, $log, $sanitizerService); } /** * Load by User Id * @param int $userId * @return array[UserOption] */ public function getByUserId($userId) { return $this->query(null, array('userId' => $userId)); } /** * Create Empty * @return UserOption */ public function createEmpty() { return new UserOption($this->getStore(), $this->getLog()); } /** * Create a user option * @param int $userId * @param string $option * @param mixed $value * @return UserOption */ public function create($userId, $option, $value) { $userOption = $this->createEmpty(); $userOption->userId = $userId; $userOption->option = $option; $userOption->value = $value; return $userOption; } /** * Query User options * @param array $sortOrder * @param array $filterBy * @return array[UserOption] */ public function query($sortOrder = null, $filterBy = []) { $parsedFilter = $this->getSanitizer($filterBy); $entries = []; $sql = 'SELECT * FROM `useroption` WHERE userId = :userId'; foreach ($this->getStore()->select($sql,['userId' => $parsedFilter->getInt('userId')]) as $row) { $entries[] = $this->createEmpty()->hydrate($row); } return $entries; } }