public function updateObject(Ad $object) { $path = $object->getPath(); if (!preg_match('|^https?://|', $path)) { $object->setUploadRootDir($this->getConfigurationPool()->getContainer()->get('kernel')->getRootDir() . '/../web/'); $object->upload('setPath'); } }
/** * Returns ad data as a simple array, useful for ajax usage * @param Ad $ad * @return array */ public static function getAdData(Ad $ad, Container $container) { $path = $ad->getPath(); $src = null; $href = null; if ($ad->getLeadsTo() !== null) { $href = $container->get('router')->generate('_sar_landing_page', array('slug' => $ad->getSlug()), true); } if (preg_match('|^https?://|', $path)) { $src = $path; } else { $src = $container->get('router')->generate('_sar_file', array('slug' => $ad->getSlug()), true); } return array('filetype' => preg_match('/\\.swf$/', $ad->getPath()) ? 'flash' : 'image', 'pos' => preg_replace('/\\D/', '', microtime()), 'slug' => $ad->getSlug(), 'type' => $ad->getType()->getId(), 'title' => $ad->getTitle(), 'params' => $ad->getType()->getDefinition(), 'src' => $src, 'href' => $href); }