public function getType($slug) { $key = 'Banner:Types'; if (!is_array($this->types)) { $types = $this->memcache->get($key); if ($this->memcache->notFound()) { $bannerTypes = $this->doctrine->getManager()->getRepository('AciliaBannerBundle:BannerType')->findAll(); $types = array(); foreach ($bannerTypes as $bannerType) { $types[$bannerType->getSlug()] = $bannerType->getId(); } $this->memcache->set($key, $types, 1440); } $this->types = $types; } if (isset($this->types[$slug])) { return $this->types[$slug]; } elseif (isset($this->types['none'])) { return $this->types['none']; } else { return 0; } }