Target.php 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. <?php
  2. /**
  3. * Zend Framework
  4. *
  5. * LICENSE
  6. *
  7. * This source file is subject to the new BSD license that is bundled
  8. * with this package in the file LICENSE.txt.
  9. * It is also available through the world-wide-web at this URL:
  10. * http://framework.zend.com/license/new-bsd
  11. * If you did not receive a copy of the license and are unable to
  12. * obtain it through the world-wide-web, please send an email
  13. * to license@zend.com so we can send you a copy immediately.
  14. *
  15. * @category Zend
  16. * @package Zend_Pdf
  17. * @subpackage Actions
  18. * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
  19. * @license http://framework.zend.com/license/new-bsd New BSD License
  20. * @version $Id$
  21. */
  22. /** Zend_Pdf_ElementFactory */
  23. require_once 'Zend/Pdf/ElementFactory.php';
  24. /**
  25. * PDF target (action or destination)
  26. *
  27. * @package Zend_Pdf
  28. * @subpackage Actions
  29. * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
  30. * @license http://framework.zend.com/license/new-bsd New BSD License
  31. */
  32. abstract class Zend_Pdf_Target
  33. {
  34. /**
  35. * Parse resource and return it as an Action or Explicit Destination
  36. *
  37. * $param Zend_Pdf_Element $resource
  38. * @return Zend_Pdf_Destination|
  39. * @throws Zend_Pdf_Exception
  40. */
  41. public static function load(Zend_Pdf_Element $resource) {
  42. if ($resource->getType() == Zend_Pdf_Element::TYPE_DICTIONARY) {
  43. // Load destination as appropriate action
  44. return Zend_Pdf_Action::load($resource);
  45. } else if ($resource->getType() == Zend_Pdf_Element::TYPE_ARRAY ||
  46. $resource->getType() == Zend_Pdf_Element::TYPE_NAME ||
  47. $resource->getType() == Zend_Pdf_Element::TYPE_STRING) {
  48. // Resource is an array, just treat it as an explicit destination array
  49. return Zend_Pdf_Destination::load($resource);
  50. } else {
  51. require_once 'Zend/Pdf/Exception.php';
  52. throw new Zend_Pdf_Exception( 'Wrong resource type.' );
  53. }
  54. }
  55. /**
  56. * Get resource
  57. *
  58. * @internal
  59. * @return Zend_Pdf_Element
  60. */
  61. abstract public function getResource();
  62. }