View Source

<ac:macro ac:name="unmigrated-inline-wiki-markup"><ac:plain-text-body><![CDATA[{zone-template-instance:ZFPROP:Proposal Zone Template}

{zone-data:component-name}
Zend_Service_ShortenUrl
{zone-data}

{zone-data:proposer-list}
[Martin Hujer|mailto:mhujer@gmail.com]
{zone-data}

{zone-data:liaison}
[~freak]
{zone-data}

{zone-data:revision}
1.0 - 12th August 2008: Initial Draft.
8th December 2008: Refactored, code and tests added
24th December 2008: Refactored according to comment
{zone-data}

{zone-data:overview}
Zend_Service_ShortenUrl provide a simple interface to access different url-shortening services. It will use adapter design pattern.
{zone-data}

{zone-data:references}
* [Zend_Service_JdemCz proposal|http://framework.zend.com/wiki/display/ZFPROP/Zend_Service_JdemCz+-+Martin+Hujer]
* [CODE and TESTs|http://zfdev.googlecode.com/svn/trunk/Mhujer_Service_ShortenUrl/]
{zone-data}

{zone-data:requirements}
* This component *must allow* to shorten any URL.
* This component *will* have method to get the target location of shortened URL (if the service supports it)
{zone-data}

{zone-data:dependencies}
* Zend_Service_Abstract
* Zend_Exception
* Zend_Http
{zone-data}

{zone-data:operation}
...
{zone-data}

{zone-data:milestones}
* Milestone 1: Finalize this proposal
* Milestone 2: Working prototype checked into SVN.
* Milestone 3: Unit tests exist, work, and are checked into SVN.
* Milestone 4: Community and Zend review
{zone-data}

{zone-data:class-list}
* Zend_Service_ShortenUrl
* Zend_Service_ShortenUrl_Exception
* Zend_Service_ShortenUrl_Abstract
* Zend_Service_ShortenUrl_TinyUrlCom
* ZendXe_Service_ShortenUrl_JdemCz
{zone-data}

{zone-data:use-cases}
{composition-setup}

{deck:id=use-cases1}

{card:label=UC 1: URL shortening}
{code:type=php}
$url = "http://framework.zend.com";
$jdemCz = new Mhujer_Service_ShortenUrl_JdemCz();
echo $jdemCz->shorten($url); //prints "http://jdem.cz/ab2l1";
{code}
{card}

{card:label=UC 2: Short URL target}
{code:type=php}
$shortUrl = "http://jdem.cz/ab2l1";
$jdemCz = new Mhujer_Service_ShortenUrl_JdemCz();
echo $jdemCz->unshorten($shortUrl); //prints 'http://framework.zend.com/';
{code}
{card}

{deck}
{zone-data}

{zone-data:skeletons}
{code}
abstract class Mhujer_Service_ShortenUrl_Abstract extends Zend_Service_Abstract
{
/**
* This function shortens long url
*
* @param string $url URL to Shorten
* @return string New URL
*/
abstract public function shorten($url);

/**
* Reveals target for short URL
*
* @param string $shortenedUrl URL to reveal target of
* @return string
*/
abstract public function unshorten($shortenedUrl);
}
{code}
{zone-data}

{zone-template-instance}]]></ac:plain-text-body></ac:macro>