/**
  * @group legacy
  */
 public function testLegacyGetUrl()
 {
     $versionStrategy = new StaticVersionStrategy('22', '%s?version=%s');
     $package = new Package($versionStrategy);
     $imagePackage = new PathPackage('images', $versionStrategy);
     $packages = new Packages($package, array('images' => $imagePackage));
     $helper = new AssetsHelper($packages);
     $this->assertEquals('me.png?version=42', $helper->getUrl('me.png', null, '42'));
     $this->assertEquals('/images/me.png?version=42', $helper->getUrl('me.png', 'images', '42'));
 }
 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;
 }
Example #3
0
 /**
  * @group legacy
  */
 public function testLegacyGetUrl()
 {
     $package = new Package(new StaticVersionStrategy('22', '%s?version=%s'));
     $packages = new Packages($package);
     $helper = new AssetsHelper($packages);
     $this->assertEquals('me.png?version=42', $helper->getUrl('me.png', null, '42'));
 }
 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;
 }
Example #5
0
 /**
  * @group legacy
  */
 public function testLegacyGetUrl()
 {
     $this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
     $package = new Package(new StaticVersionStrategy('22', '%s?version=%s'));
     $packages = new Packages($package);
     $helper = new AssetsHelper($packages);
     $this->assertEquals('me.png?version=42', $helper->getUrl('me.png', null, '42'));
 }
 protected function doRender(array $packages, $format)
 {
     $html = '';
     foreach ($packages as $packageName => $attributes) {
         try {
             $package = $this->manager->get($packageName, $format);
             if (false === $package->options->get('package_assets', $this->options['package_assets'])) {
                 foreach ($package->paths as $path) {
                     $html .= $this->renderTag($this->assetsHelper->getUrl($path), $format, $attributes);
                 }
                 continue;
             }
             $html .= $this->renderTag($this->generatePackageURL($this->manager->compress($package), $format), $format, $attributes);
         } catch (\InvalidArgumentException $ex) {
             // No Package found
             $html .= $this->renderTag($this->assetsHelper->getUrl($packageName), $attributes);
         }
     }
     return $html;
 }
 /**
  * @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);
 }