Example #1
0
 public function testGetEntryExceptionInvalidLocationType()
 {
     $gdata = new GData\GData();
     try {
         // give it neither a string nor a Zend_GData_Query object,
         // and see if it throws an exception.
         $feed = $gdata->getEntry(new \stdClass());
         $this->fail('Expecting to catch Zend\\GData\\App\\InvalidArgumentException');
     } catch (\Zend\Exception $e) {
         $this->assertType('Zend\\GData\\App\\InvalidArgumentException', $e, 'Expecting Zend\\GData\\App\\InvalidArgumentException, got ' . get_class($e));
         $this->assertEquals('You must specify the location as either a string URI or a child of Zend\\GData\\Query', $e->getMessage());
     }
 }
Example #2
0
 /**
  * Retrieve data feed object
  *
  * @param mixed $location
  * @return Analytics\DataFeed
  */
 public function getDataFeed($location = self::ANALYTICS_FEED_URI)
 {
     if ($location instanceof Query) {
         $uri = $location->getQueryUrl();
     } else {
         $uri = $location;
     }
     return parent::getFeed($uri, 'Zend\\GData\\Analytics\\DataFeed');
 }
Example #3
0
 /**
  * Gets a list entry.
  *
  * @param string $location A ListQuery or a URI specifying the entry location.
  * @return ListEntry
  */
 public function getListEntry($location)
 {
     if ($location instanceof ListQuery) {
         $uri = $location->getQueryUrl();
     } else {
         $uri = $location;
     }
     return parent::getEntry($uri, '\\Zend\\GData\\Spreadsheets\\ListEntry');
 }
Example #4
0
 /**
  * Provides a magic factory method to instantiate new objects with
  * shorter syntax than would otherwise be required by the Zend Framework
  * naming conventions. For more information, see Zend_Gdata_App::__call().
  *
  * This overrides the default behavior of __call() so that query classes
  * do not need to have their domain manually set when created with
  * a magic factory method.
  *
  * @see Zend_Gdata_App::__call()
  * @param string $method The method name being called
  * @param array $args The arguments passed to the call
  * @throws \Zend\GData\App\Exception
  */
 public function __call($method, $args)
 {
     if (preg_match('/^new(\\w+Query)/', $method, $matches)) {
         $class = $matches[1];
         $foundClassName = null;
         foreach ($this->_registeredPackages as $name) {
             try {
                 // Autoloading disabled on next line for compatibility
                 // with magic factories. See ZF-6660.
                 if (!class_exists($name . '\\' . $class, false)) {
                     @\Zend\Loader::loadClass($name . '\\' . $class);
                 }
                 $foundClassName = $name . '\\' . $class;
                 break;
             } catch (\Zend\Exception $e) {
                 // package wasn't here- continue searching
             }
         }
         if ($foundClassName != null) {
             $reflectionObj = new \ReflectionClass($foundClassName);
             // Prepend the domain to the query
             $args = array_merge(array($this->getDomain()), $args);
             return $reflectionObj->newInstanceArgs($args);
         } else {
             throw new App\Exception("Unable to find '{$class}' in registered packages");
         }
     } else {
         return parent::__call($method, $args);
     }
 }
Example #5
0
 /**
  * Create Zend_Gdata_Exif object
  *
  * @param \Zend\HTTP\Client $client (optional) The HTTP client to use when
  *          when communicating with the Google servers.
  * @param string $applicationId The identity of the app in the form of Company-AppName-Version
  */
 public function __construct($client = null, $applicationId = 'MyCompany-MyApp-1.0')
 {
     $this->registerPackage('\\Zend\\GData\\EXIF');
     $this->registerPackage('\\Zend\\GData\\EXIF\\Extension');
     parent::__construct($client, $applicationId);
 }
Example #6
0
 public function testDisableAndReEnableXMLToObjectMappingReturnsObject()
 {
     $gdata = new GData\GData();
     $gdata::useObjectMapping(false);
     $xmlString = $gdata->getEntry('http://gdata.youtube.com/feeds/api/videos/O4SWAfisH-8');
     $this->assertEquals('string', gettype($xmlString));
     $gdata::useObjectMapping(true);
     $entry = $gdata->getEntry('http://gdata.youtube.com/feeds/api/videos/O4SWAfisH-8');
     $this->assertTrue($entry instanceof GData\Entry);
 }
Example #7
0
 /**
  * Retreive entryobject
  *
  * @return \Zend\GData\Calendar\ListEntry
  */
 public function getCalendarListEntry($location = null)
 {
     if ($location == null) {
         throw new App\InvalidArgumentException('Location must not be null');
     } else {
         if ($location instanceof GData\Query) {
             $uri = $location->getQueryUrl();
         } else {
             $uri = $location;
         }
     }
     return parent::getEntry($uri, '\\Zend\\GData\\Calendar\\ListEntry');
 }
Example #8
0
 /**
  * Insert a Volume / Annotation
  *
  * @param \Zend\GData\Books\VolumeEntry $entry
  * @param \Zend\GData\Query|string|null $location (optional) The URL to
  *        query
  * @return \Zend\GData\Books\VolumeEntry The inserted volume entry.
  */
 public function insertVolume($entry, $location = null)
 {
     if ($location == null) {
         $uri = self::MY_LIBRARY_FEED_URI;
     } else {
         $uri = $location;
     }
     return parent::insertEntry($entry, $uri, '\\Zend\\GData\\Books\\VolumeEntry');
 }
Example #9
0
 /**
  * Retreive a single CommentEntry object.
  *
  * @param mixed $location The location for the feed, as a URL or Query.
  * @return \Zend\GData\Photos\CommentEntry
  * @throws \Zend\GData\App\Exception
  * @throws \Zend\GData\App\HttpException
  */
 public function getCommentEntry($location)
 {
     if ($location === null) {
         throw new App\InvalidArgumentException('Location must not be null');
     } else {
         if ($location instanceof UserQuery) {
             $location->setType('entry');
             $uri = $location->getQueryUrl();
         } else {
             if ($location instanceof GData\Query) {
                 $uri = $location->getQueryUrl();
             } else {
                 $uri = $location;
             }
         }
     }
     return parent::getEntry($uri, '\\Zend\\GData\\Photos\\CommentEntry');
 }
Example #10
0
 /**
  * Retrieve a profile entry object
  *
  * @param mixed $query The query for the feed, as a URL or Query
  * @return \Zend\GData\Health\ProfileEntry
  */
 public function getHealthProfileEntry($query = null)
 {
     if ($query === null) {
         throw new GData\App\InvalidArgumentException('Query must not be null');
     } else {
         if ($query instanceof GData\Query) {
             $uri = $query->getQueryUrl();
         } else {
             $uri = $query;
         }
     }
     return parent::getEntry($uri, '\\Zend\\GData\\Health\\ProfileEntry');
 }
Example #11
0
 /**
  * Retrieve feed object
  *
  * @param mixed $location The location for the feed, as a URL or Query
  * @return \Zend\GData\GBase\SnippetFeed
  */
 public function getGBaseSnippetFeed($location = null)
 {
     if ($location === null) {
         $uri = self::GBASE_SNIPPET_FEED_URI;
     } else {
         if ($location instanceof GData\Query) {
             $uri = $location->getQueryUrl();
         } else {
             $uri = $location;
         }
     }
     return parent::getFeed($uri, '\\Zend\\GData\\GBase\\SnippetFeed');
 }