<?php require_once dirname(dirname(__DIR__)) . DIRECTORY_SEPARATOR . 'Bootstrap.php'; use Zend\Service\LiveDocx\Helper; use Zend\Service\LiveDocx\MailMerge; Helper::printLine(PHP_EOL . 'Template, Document and Image Formats' . PHP_EOL . PHP_EOL . 'The following formats are supported by LiveDocx:' . PHP_EOL . PHP_EOL); $mailMerge = new MailMerge(); $mailMerge->setUsername(DEMOS_ZEND_SERVICE_LIVEDOCX_USERNAME)->setPassword(DEMOS_ZEND_SERVICE_LIVEDOCX_PASSWORD); printf("Supported TEMPLATE file formats (input) : %s%s", Helper::arrayDecorator($mailMerge->getTemplateFormats()), PHP_EOL); printf("Supported DOCUMENT file formats (output) : %s%s", Helper::arrayDecorator($mailMerge->getDocumentFormats()), PHP_EOL); printf("Supported IMAGE file formats (output) : %s%s", Helper::arrayDecorator($mailMerge->getImageFormats()), PHP_EOL); print PHP_EOL; unset($mailMerge);
require_once dirname(dirname(__DIR__)) . DIRECTORY_SEPARATOR . 'Bootstrap.php'; use Zend\Cache\Cache; use Zend\Service\LiveDocx\Helper; use Zend\Service\LiveDocx\MailMerge; Helper::printLine(PHP_EOL . 'Template, Document and Image Formats' . PHP_EOL . PHP_EOL . 'The following formats are supported by LiveDocx:' . PHP_EOL . PHP_EOL . '(Note these method calls are cached for maximum performance. The supported formats change very infrequently, hence, they are good candidates to be cached.)' . PHP_EOL . PHP_EOL); $cacheId = md5(__FILE__); $cacheFrontendOptions = array('lifetime' => 2592000, 'automatic_serialization' => true); $cacheBackendOptions = array('cache_dir' => __DIR__ . '/cache'); if (!is_dir($cacheBackendOptions['cache_dir'])) { mkdir($cacheBackendOptions['cache_dir']); } $cache = Cache::factory('Core', 'File', $cacheFrontendOptions, $cacheBackendOptions); if (!($formats = $cache->load($cacheId))) { // Cache miss. Connect to backend service (expensive). $mailMerge = new MailMerge(); $mailMerge->setUsername(DEMOS_ZEND_SERVICE_LIVEDOCX_USERNAME)->setPassword(DEMOS_ZEND_SERVICE_LIVEDOCX_PASSWORD); $formats = new \StdClass(); $formats->template = $mailMerge->getTemplateFormats(); $formats->document = $mailMerge->getDocumentFormats(); $formats->image = $mailMerge->getImageFormats(); $cache->save($formats, $cacheId); unset($mailMerge); } else { // Cache hit. Continue. } unset($cache); printf("Supported TEMPLATE file formats (input) : %s%s", Helper::arrayDecorator($formats->template), PHP_EOL); printf("Supported DOCUMENT file formats (output) : %s%s", Helper::arrayDecorator($formats->document), PHP_EOL); printf("Supported IMAGE file formats (output) : %s%s", Helper::arrayDecorator($formats->image), PHP_EOL); print PHP_EOL;
<?php require_once dirname(dirname(__DIR__)) . DIRECTORY_SEPARATOR . 'Bootstrap.php'; use Zend\Config\Ini; use Zend\Service\LiveDocx\Helper; use Zend\Service\LiveDocx\MailMerge; Helper::printLine(PHP_EOL . 'Using the Public LiveDocx Service with \\Zend\\Config\\Config' . PHP_EOL . PHP_EOL . 'This sample application illustrates how to use the Zend Framework LiveDocx component with a \\Zend\\Config\\Config object. This is useful, for example, to store connection credentials in an external ini file.' . PHP_EOL . PHP_EOL); $options = new Ini('credentials.ini'); $mailMerge = new MailMerge($options); $mailMerge->getTemplateFormats(); // then call methods as usual printf('Username : %s%sPassword : %s%s WSDL : %s%s%s', $mailMerge->getUsername(), PHP_EOL, $mailMerge->getPassword(), PHP_EOL, $mailMerge->getWSDL(), PHP_EOL, PHP_EOL); unset($mailMerge, $options);
use Zend\Config\Factory as ConfigFactory; use Zend\Service\LiveDocx\Helper; use Zend\Service\LiveDocx\MailMerge; Helper::printLine( PHP_EOL . 'Using the Public LiveDocx Service with \Zend\Config\Config' . PHP_EOL . PHP_EOL . 'This sample application illustrates how to use the Zend Framework LiveDocx component with a \Zend\Config\Config object. This is useful, for example, to store connection credentials in an external ini file.' . PHP_EOL . PHP_EOL ); $options = ConfigFactory::fromFile('credentials.ini', true); $mailMerge = new MailMerge($options); $mailMerge->getTemplateFormats(); // then call methods as usual printf('Username : %s%sPassword : %s%s WSDL : %s%s%s', $mailMerge->getUsername(), PHP_EOL, $mailMerge->getPassword(), PHP_EOL, $mailMerge->getWsdl(), PHP_EOL, PHP_EOL ); unset($mailMerge, $options);