/** * Get the instance as an array. * * @return array */ public function toArray() { $arr = array('container' => $this->container, 'format' => $this->format, 'notifications' => $this->notifications->toArray()); return $arr; }
/** * Returns all messages for given type. * * @param $type * @return \Krucas\Notification\Collection */ public function get($type) { $collection = new Collection(); foreach ($this->notifications as $key => $message) { if ($message->getType() == $type) { if (!is_null($message->getPosition())) { $collection->setAtPosition($key, $message); } else { $collection->addUnique($message); } } } return $collection; }
/** * Get the instance as an array. * * @return array */ public function toArray() { $arr = array('container' => $this->container, 'format' => $this->getDefaultFormat(), 'types' => $this->getTypes(), 'notifications' => $this->notifications->toArray()); return $arr; }
/** * Clears message for a given type. * * @param null $type * @return \Krucas\Notification\NotificationsBag */ public function clear($type = null) { if (is_null($type)) { $this->notifications = new Collection(); } else { $notifications = new Collection(); foreach ($this->notifications as $message) { if ($message->getType() != $type) { $notifications->add($message); } } $this->notifications = $notifications; } return $this; }