public function renderEdit($id, $day) { $this->template->_form = $this['itemForm']; $workedHours = null; if ($this->listingItem instanceof Entities\ListingItem and !$this->listing->isDetached()) { $workedHours = $this->listingItem->workedHours->getHours(); } $this->template->itemDate = $this->date; $this->template->listing = $this->listing; $this->template->workedHours = $workedHours; $this->template->defaultWorkedHours = $this->itemUpdateFormFactory->getDefaultTimeValue('workedHours'); }
/** * @param Entities\ListingItem[] $listingItems * @param Entities\Listing $listing * @return array */ public function setListingForGivenItems(array $listingItems, Entities\Listing $listing) { if ($listing->isDetached()) { throw new InvalidArgumentException('Only attached(not detached) ' . Entities\Listing::class . ' entity can pass!'); } $newItemsCollection = []; foreach ($listingItems as $listingItem) { if (!$listingItem instanceof Entities\ListingItem) { throw new InvalidArgumentException('Only instances of ' . Entities\ListingItem::class . ' can pass.'); } $listingItem->setListing($listing); $newItemsCollection[] = $listingItem; } return $newItemsCollection; }
/** * @param Listing $listing * @throws InvalidArgumentException */ private function checkListingValidity(Listing $listing) { if ($listing->isDetached()) { throw new InvalidArgumentException('Argument $listing must be attached instance of ' . Listing::class); } }