/** * Do not use to construct new stuff from outside of this class, * use the static newFoobar methods. * * In other words: treat as protected (which it was, but now * cannot be since we derive from Content). * * @protected * * @param EntityHolder $propertyHolder * @throws InvalidArgumentException */ public function __construct(EntityHolder $propertyHolder) { parent::__construct(CONTENT_MODEL_WIKIBASE_PROPERTY); if ($propertyHolder->getEntityType() !== Property::ENTITY_TYPE) { throw new InvalidArgumentException('$propertyHolder must contain a Property entity!'); } $this->propertyHolder = $propertyHolder; }
/** * Do not use to construct new stuff from outside of this class, * use the static newFoobar methods. * * In other words: treat as protected (which it was, but now * cannot be since we derive from Content). * * @protected * * @param EntityHolder $mediumHolder * @throws InvalidArgumentException */ public function __construct(EntityHolder $mediumHolder) { parent::__construct(CONTENT_MODEL_WIKIBASE_MEDIAINFO); if ($mediumHolder->getEntityType() !== MediaInfo::ENTITY_TYPE) { throw new InvalidArgumentException('$mediumHolder must contain a Medium entity!'); } $this->mediumHolder = $mediumHolder; }
/** * Do not use to construct new stuff from outside of this class, * use the static newFoobar methods. * * In other words: treat as protected (which it was, but now cannot * be since we derive from Content). * * @param EntityHolder|null $itemHolder * @param EntityRedirect|null $entityRedirect * @param Title|null $redirectTitle Title of the redirect target. * * @throws InvalidArgumentException */ public function __construct(EntityHolder $itemHolder = null, EntityRedirect $entityRedirect = null, Title $redirectTitle = null) { parent::__construct(CONTENT_MODEL_WIKIBASE_ITEM); if (is_null($itemHolder) === is_null($entityRedirect)) { throw new InvalidArgumentException('Either $item or $entityRedirect and $redirectTitle must be provided.'); } if ($itemHolder !== null && $itemHolder->getEntityType() !== Item::ENTITY_TYPE) { throw new InvalidArgumentException('$itemHolder must contain a Item entity!'); } if (is_null($entityRedirect) !== is_null($redirectTitle)) { throw new InvalidArgumentException('$entityRedirect and $redirectTitle must both be provided or both be empty.'); } if ($redirectTitle !== null && $redirectTitle->getContentModel() !== CONTENT_MODEL_WIKIBASE_ITEM) { if ($redirectTitle->exists()) { throw new InvalidArgumentException('$redirectTitle must refer to a page with content model ' . CONTENT_MODEL_WIKIBASE_ITEM); } } $this->itemHolder = $itemHolder; $this->redirect = $entityRedirect; $this->redirectTitle = $redirectTitle; }