Weitere ähnliche Inhalte
Ähnlich wie What's New in ZF 1.10 (20)
Mehr von Ralph Schindler (12)
Kürzlich hochgeladen (20)
What's New in ZF 1.10
- 1. What's New in ZF 1.10? Ralph Schindler Zend Framework Software Engineer
- 20. $renderer = Zend_Barcode::factory( 'code39' , // barcode type 'image' , // image or PDF array ( // barcode options 'text' => 'ZENDFRAMEWORK' , ), array ( // renderer options 'imageType' => 'png' , ) ); $image = $renderer ->draw(); imagepng ( $image , __DIR__ . '/barcode.png' );
- 21. $validator = new Zend_Validate_Barcode( 'CODE39' ); if ( $validator ->isValid( $input )) { // valid barcode text } else { // invalid barcode text }
- 24. $options = array ( 'public_dir' => APPLICATION_PATH . '/../public/cache' , ); // Where $manager is a Zend_Cache_Manager instance $manager ->setTemplateOptions( 'page' , $options ); $cache = $manager ->getCache( 'page' ); // In an action controller: public function preDispatch() { $this ->_helper->cache( // cache these actions: array ( 'foo' , 'bar' , 'baz' ), // use these tags: array ( $this ->_request->getControllerName()), // with this extension: 'html' ); }
- 25. $manager = new Zend_Cache_Manager; $dbCache = array ( 'frontend' => array ( 'name' => 'Core' , 'options' => array ( 'lifetime' => 3600, 'automatic_serialization' => true, ) ), 'backend' => array ( 'name' => 'Core' , 'options' => array ( 'cache_dir' => APPLICATION_PATH . '/../data/cache/db' , ), ), ); $manager ->setCacheTemplate( 'db' , $dbCache ); $cache = $manager ->getCache( 'db' );
- 27. $feed = new Zend_Feed_Writer_Feed; $feed ->setTitle( 'ZF Webinars' ) ->setLink( 'http://framework.zend.com/webinars/atom' , 'atom' ) ->addAuthor( array ( 'name' => 'ZF DevTeam' , 'email' => 'fw-general@lists.zend.com' , 'uri' => 'http://framework.zend.com/' , )) ->setDateModified( strtotime ( '2010-03-17 12:00:00' ));
- 28. $entry = $feed ->createEntry(); $entry ->setLink( 'http://framework.zend.com/webinars/2010-03-17' ) ->addAuthor( array ( 'name' => 'Ralph Schindler' , 'email' => 'ralph.schindler@zend.com' , 'uri' => 'http://framework.zend.com/' , )) ->setDateModified( strtotime ( '2010-03-17 12:00:00' )) ->setDateCreated( strtotime ( '2010-03-15 08:39:00' )); $output = $feed ->export( 'atom' );
- 30. $publisher = new Zend_Feed_Pubsubhubbub_Publisher; $publisher ->addHubUrls( array ( 'http://pubsubhubbub.appspot.com/' , 'http://wordpress.org/extend/plugins/pushpress/' , )) ->addUpdatedTopicUrls( array ( 'http://framework.zend.com/webinars/atom' , )); // Notify $publisher ->notifyAll();
- 31. $storage = new Zend_Feed_Pubsubhubbub_Model_Subscription; $subscriber = new Zend_Feed_Pubsubhubbub_Subscriber; $subscriber ->setStorage( $storage ) ->addHubUrl( 'http://pubsubhubbub.appspot.com/' ) ->setTopicUrl( 'http://framework.zend.com/webinars/atom' ) ->setCallbackUrl( 'http://www.mydomain.com/hubbub/callback' ) ->subscribeAll();
- 32. $callback = new Zend_Feed_Pubsubhubbub_Subscriber_Callback; $callback ->setStorage( $storage ); $callback ->handle(); $callback ->sendResponse(); if ( $callback ->hasFeedUpdate()) { $feedString = $callback ->getFedUpdate(); // start processing! }
- 35. $config = array ( 'callbackUrl' => 'http://example.com/callback' , 'siteUrl' => 'http://twitter.com/oauth' , 'consumerKey' => 'gg3DsFTW9OU9eWPnbuPzQ' , 'consumerSecret' => 'tFB0fyWLSMf74lkEu9FTyoHXcazOWpbrAjTCCK48A' ); $consumer = new Zend_Oauth_Consumer( $config ); // Get request token: $token = $consumer ->getRequestToken(); // Persist the token $session = new Zend_Session_Namespace( 'oauth' ); $session ->token = serialize ( $token ); // Redirect to oauth provider $consumer ->redirect();
- 36. // Within a controller action, assuming consumer // and session setup above $request = $this ->getRequest(); if (! $request ->isGet() || !isset( $session ->token) ) { // error condition! } $token = $consumer ->getAccessToken( $request ->getQuery(), unserialize ( $session ->token) ); // use the token! $client = $token ->getHttpClient(); // ...
- 38. $serializer = Zend_Serializer::factory( 'Json' ); $serialized = $serializer -> serialize ( $data ); $unserialized = $serializer -> unserialize ( $serialized );