public function execute(Location $location)
 {
     // Set HTML title as Location name.
     $location->setName('Form on ' . ParserUtil::getHTMLTitle($location->getUrl()));
     // Set the Website page module as the Location module.
     $locationModule = $this->locationService->getLocationModule('campaignchain/location-website', 'campaignchain-website-form');
     $location->setLocationModule($locationModule);
     // Set the image.
     $location->setImage($this->assetsHelper->getUrl('bundles/campaignchainlocationwebsite/images/icons/256x256/form.png', null));
     return $location;
 }
 /**
  * @group legacy
  */
 public function testLegacyGetVersion()
 {
     $package = new Package(new StaticVersionStrategy('22'));
     $imagePackage = new Package(new StaticVersionStrategy('42'));
     $packages = new Packages($package, array('images' => $imagePackage));
     $helper = new AssetsHelper($packages);
     $this->assertEquals('22', $helper->getVersion());
     $this->assertEquals('22', $helper->getVersion('/foo'));
     $this->assertEquals('42', $helper->getVersion('images'));
     $this->assertEquals('42', $helper->getVersion('/foo', 'images'));
 }
 /**
  * @group legacy
  */
 public function testLegacyGetVersion()
 {
     $this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
     $package = new Package(new StaticVersionStrategy('22'));
     $imagePackage = new Package(new StaticVersionStrategy('42'));
     $packages = new Packages($package, array('images' => $imagePackage));
     $helper = new AssetsHelper($packages);
     $this->assertEquals('22', $helper->getVersion());
     $this->assertEquals('22', $helper->getVersion('/foo'));
     $this->assertEquals('42', $helper->getVersion('images'));
     $this->assertEquals('42', $helper->getVersion('/foo', 'images'));
 }
 public function publishOnPage(Post $post, $message = null)
 {
     $response = new FacebookPostAsPageResponse();
     $accessToken = $this->getUserLongAccessToken();
     if (!$post->getPublished()) {
         return $response->setException(new \Exception('flash_batch_facebook_post_not_published'));
     }
     if ($accessToken->tokenIsEmpty()) {
         return $response->setException(new \Exception('flash_batch_facebook_access_token_empty'));
     }
     $this->application->setDefaultAccessToken($accessToken->getAccessToken());
     try {
         $getPageAccessToken = $this->application->sendRequest('GET', '/' . $this->pageId, array('fields' => 'access_token'))->getDecodedBody();
         $params = array('message' => null !== $message ? $message : '', 'name' => $post->getTitle(), 'caption' => $post->getDescription(), 'link' => $this->router->generate('front_article_view', array('slug' => $post->getSlug()), true));
         if (count($post->getImages()) > 0) {
             $hompage = $this->router->generate('homepage', array(), true);
             $imgWebPath = $this->assetsHelper->getUrl($post->getPreviewImage()->getWebPath());
             $params['picture'] = $hompage . $imgWebPath;
         }
         $endPoint = null === $post->getFbId() ? $this->pageId . '/feed' : $post->getFbId();
         $postAsPage = $this->application->post('/' . $endPoint, $params, $getPageAccessToken['access_token'])->getDecodedBody();
         $response->setId(isset($postAsPage['id']) ? $postAsPage['id'] : $post->getFbId());
     } catch (\Exception $e) {
         return $response->setException($e);
     }
     return $response;
 }
 /**
  * Render the html tag.
  *
  * @return String html tag
  */
 protected function renderTag($path, $format, array $attributes = array())
 {
     $atts = '';
     foreach ($attributes as $key => $value) {
         $atts .= ' ' . sprintf('%s="%s"', $key, htmlspecialchars($value, ENT_QUOTES, $this->assetsHelper->getCharset()));
     }
     if ('css' === $format) {
         return sprintf('<link href="%s" rel="stylesheet" type="text/css"%s />', $path, $atts) . "\n";
     }
     return sprintf('<script type="text/javascript" src="%s"%s></script>', $path, $atts) . "\n";
 }
Exemple #6
0
 public function getConfiguration()
 {
     $config = ['paths' => [], 'shim' => []];
     if (isset($this->configuration['paths']) && is_array($this->configuration['paths'])) {
         foreach ($this->configuration['paths'] as $name => $path) {
             $config['paths'][$name] = $path['location'];
         }
         foreach ($this->configuration['paths'] as $name => $path) {
             $config['shim'][$name] = [];
             if (isset($path['exports'])) {
                 $config['shim'][$name]['exports'] = $path['exports'];
             }
             if (isset($path['dependencies'])) {
                 $config['shim'][$name]['deps'] = $path['dependencies'];
             }
         }
     }
     if ($this->assetsHelper->getVersion()) {
         $config['urlArgs'] = $this->assetsHelper->getVersion();
     }
     return $config;
 }
 /**
  * @param PreSerializeEvent $event
  */
 public function onPerSerializeGlavwebMediaFile(PreSerializeEvent $event)
 {
     $entity = $event->getObject();
     $type = $event->getType();
     $className = $type['name'];
     $request = $this->requestStack->getCurrentRequest();
     $reflectionClass = new \ReflectionClass($className);
     $media = array();
     $classProperties = $reflectionClass->getProperties();
     foreach ($classProperties as $property) {
         $uploadableFieldAnnotation = $this->annotationsReader->getPropertyAnnotation($property, 'Glavweb\\UploaderBundle\\Mapping\\Annotation\\UploadableField');
         if ($uploadableFieldAnnotation) {
             /** @var ImagineFilters $imagineFiltersAnnotation */
             $imagineFiltersAnnotation = $this->annotationsReader->getPropertyAnnotation($property, 'Glavweb\\CoreBundle\\Mapping\\Annotation\\ImagineFilters');
             if (!$imagineFiltersAnnotation) {
                 continue;
             }
             $imagineFilterProperty = $imagineFiltersAnnotation->getProperty();
             $getter = 'get' . ucfirst($property->getName());
             $items = $entity->{$getter}();
             if (!is_array($items) && !$items instanceof \Traversable) {
                 continue;
             }
             /** @var Media $item */
             foreach ($items as $item) {
                 $originUrl = null;
                 $thumbnails = [];
                 if ($item->getContentPath()) {
                     $originUrl = $this->mediaHelper->getContentPath($item);
                     foreach ($imagineFiltersAnnotation->getFilters() as $filter) {
                         $thumbnails[$filter] = $this->imagineHelper->filter($originUrl, $filter);
                     }
                 }
                 if ($request) {
                     $originUrl = $request->getSchemeAndHttpHost() . $originUrl;
                 }
                 $media[] = array('originUrl' => $originUrl, 'thumbnails' => $thumbnails, 'name' => $item->getName(), 'description' => $item->getDescription());
             }
             $entity->{$imagineFilterProperty} = $media;
         }
     }
 }
 /**
  * @return Location[]
  */
 public function getParsedLocationsFromLinkedIn()
 {
     $channel = $this->channelWizard->getChannel();
     $profile = $this->channelWizard->get('profile');
     $locations = [];
     $locationName = $profile->displayName;
     if (!empty($profile->username)) {
         $locationName .= ' (' . $profile->username . ')';
     }
     // Get the location module for the user stream.
     $locationModuleUser = $this->locationService->getLocationModule('campaignchain/location-linkedin', 'campaignchain-linkedin-user');
     // Create the location instance for the user stream.
     $locationUser = new Location();
     $locationUser->setIdentifier($profile->identifier);
     $locationUser->setName($locationName);
     $locationUser->setLocationModule($locationModuleUser);
     if (!$profile->photoURL || strlen($profile->photoURL) == 0) {
         $locationUser->setImage($this->assetsHelper->getUrl('/bundles/campaignchainchannellinkedin/ghost_person.png'));
     } else {
         $locationUser->setImage($profile->photoURL);
     }
     $locationUser->setChannel($channel);
     $locationModuleUser->addLocation($locationUser);
     $locations[$profile->identifier] = $locationUser;
     $tokens = $this->channelWizard->get('tokens');
     /** @var Token $userToken */
     $userToken = array_values($tokens)[0];
     $connection = $this->client->getConnectionByToken($userToken);
     $companies = $connection->getCompanies();
     //there is only a user page
     if (empty($companies)) {
         return $locations;
     }
     // Get the location module for the page stream.
     $locationModulePage = $this->locationService->getLocationModule('campaignchain/location-linkedin', 'campaignchain-linkedin-page');
     $wizardPages = [];
     foreach ($companies as $company) {
         $newToken = new Token();
         $newToken->setAccessToken($userToken->getAccessToken());
         $newToken->setApplication($userToken->getApplication());
         $newToken->setTokenSecret($userToken->getTokenSecret());
         $tokens[$company['id']] = $newToken;
         $this->channelWizard->set('tokens', $tokens);
         $companyData = $connection->getCompanyProfile($company['id']);
         $locationPage = new Location();
         $locationPage->setChannel($channel);
         $locationPage->setName($companyData['name']);
         $locationPage->setIdentifier($companyData['id']);
         if (isset($companyData['squareLogoUrl'])) {
             $locationPage->setImage($companyData['squareLogoUrl']);
         } else {
             $locationPage->setImage($this->assetsHelper->getUrl('/bundles/campaignchainchannellinkedin/ghost_person.png'));
         }
         $locationPage->setLocationModule($locationModulePage);
         $locationModulePage->addLocation($locationPage);
         $locations[$companyData['id']] = $locationPage;
         $wizardPages[$companyData['id']] = $companyData;
     }
     $this->channelWizard->set('pagesData', $wizardPages);
     return $locations;
 }
 /**
  * {@inheritdoc}
  */
 public function getUrl($key)
 {
     return $this->helper->getUrl(trim($this->directory, '/') . '/' . $key);
 }
 /**
  * Get report's asset path.
  *
  * @param BaseReport $report
  *
  * @return string
  */
 public function getReportAssetPath(BaseReport $report)
 {
     return $this->templatingHelper->getUrl($this->reportAssetsFolder . '/' . get_class($report));
 }
 public function getUrl($path, $packageName = null, $version = null)
 {
     return parent::getUrl($path, $packageName, $version);
 }