Example #1
0
 public function __construct(ClassMap $fromClassMap, $name)
 {
     $this->manager = PersistentManager::getInstance();
     $this->fromClassMap = $fromClassMap;
     $this->fromClassName = $fromClassMap->getName();
     $this->name = $name;
     $this->inverse = FALSE;
 }
Example #2
0
 public static function init()
 {
     if (!self::$isInit) {
         self::init_env();
         self::init_classmap();
         self::$isInit = true;
     }
 }
Example #3
0
 /**
  * construct mime email and send it out.
  *
  * @param string    transport backend
  */
 public function send($via = '')
 {
     //! allow temporarly override backend. Only url allowed, not array
     if (!empty($via)) {
         $this->getBackEnd(@parse_url($via));
     }
     //! sanity checks
     if (empty($this->via)) {
         throw new EmailException(L('Mailer backend not configured!'));
     }
     if (empty($this->message)) {
         throw new EmailException(L('Empty message!'));
     }
     if (empty($this->header['Subject'])) {
         throw new EmailException(L('No subject given!'));
     }
     if (empty($this->header['To'])) {
         throw new EmailException(L('No recipient given!'));
     }
     if (count($this->header['To']) > 64) {
         // @codeCoverageIgnoreStart
         throw new EmailException(L('Too many recipients!'));
     }
     // @codeCoverageIgnoreEnd
     $this->address(self::$sender, 'From');
     $local = @explode('@', array_keys($this->header['From'])[0])[1];
     if (empty($local)) {
         $local = 'localhost';
     }
     $id = sha1(uniqid()) . '_' . microtime(true) . '@' . $local;
     //! message type
     $isHtml = preg_match('/<html/i', $this->message);
     //! *** handle transport backends that does not require mime message ***
     if ($this->via == 'db') {
         //! mail queue in database
         if (empty(DS::db())) {
             throw new EmailException(L('DB queue backend without configured datasource!'));
         }
         return DS::exec('INSERT INTO email_queue (data,created) VALUES (?,?);', [$this->get(), Core::$core->now]) > 0 ? true : false;
     } elseif ($this->via == 'phpmailer') {
         //! PHP Mailer
         if (!ClassMap::has('PHPMailer')) {
             throw new EmailException(L('PHPMailer not installed!'));
         }
         // @codeCoverageIgnoreStart
         $mail = new \PHPMailer();
         $mail->Subject = $this->header['Subject'];
         $mail->SetFrom(implode(', ', $this->header['From']));
         if (!empty($this->header['Reply-To'])) {
             $mail->AddReplyTo($this->header['Reply-To']);
         }
         foreach (['To', 'Cc', 'Bcc'] as $type) {
             foreach ($this->header[$type] as $rcpt => $full) {
                 list($name) = explode('<', $full);
                 $mail->SetAddress(self::$forge ? self::$forge : $rcpt, trim($name));
             }
         }
         foreach ($this->attach as $attach) {
             $mail->AddAttachment($attach['file']);
         }
         $mail->MsgHTML($this->message);
         return $mail->Send();
         // @codeCoverageIgnoreEnd
     }
     //! *** build mime message ***
     //! mime headers
     $headers['MIME-Version'] = '1.0';
     $headers['Content-Class'] = 'urn:content-classes:message';
     $headers['Content-Type'] = 'text/plain;charset=utf-8';
     $headers['Content-Transfer-Encoding'] = '8bit';
     $headers['Sender'] = implode(', ', $this->header['From']);
     $headers['Message-ID'] = '<' . $id . '>';
     $headers['Date'] = date('r', Core::$core->now);
     $headers['X-Mailer'] = 'PHPPE ' . VERSION;
     foreach ($this->header as $k => $v) {
         $headers[$k] = is_array($v) ? implode(', ', $v) : $v;
     }
     //! mime body
     if (!$isHtml) {
         //! plain text email
         $message = wordwrap($this->message, 78);
     } else {
         $boundary = uniqid();
         //! html email with a plain text alternative
         $headers['Content-Type'] = "multipart/alternative;\n boundary=\"" . $boundary . '"';
         $message = "This is a multi-part message in MIME format.\r\n";
         $message .= '--' . $boundary . "\n" . "Content-type: text/plain;charset=utf-8\n" . "Content-Transfer-Encoding: 8bit\n\n" . wordwrap(preg_replace("/\\<.*?\\>/m", '', strtr($this->message, ['</h1>' => "\n\n", '</h2>' => "\n\n", '</h3>' => "\n\n", '</h4>' => "\n\n", '</h5>' => "\n\n", '</h6>' => "\n\n", '</p>' => "\n\n", '</td>' => "\t", '</tr>' => "\n", '</table>' => "\n", '<br>' => "\n", '<br/>' => "\n"])), 78) . "\r\n";
         //! look for images in html, if found, we have to create a multipart/related block
         if (preg_match_all("/(http|images\\/|data\\/).*?\\.(gif|png|jpe?g)/mis", $this->message, $m, PREG_OFFSET_CAPTURE | PREG_SET_ORDER)) {
             $boundary2 = uniqid();
             $diff = 0;
             foreach ($m as $k => $c) {
                 //if it's a absolute url, don't replace it
                 if ($c[1][0] == 'http') {
                     unset($m[$k]);
                     continue;
                 }
                 //generate a cid
                 $m[$k][3] = uniqid();
                 //get local path for filename
                 if ($c[1][0] == 'data/' && file_exists($c[0][0])) {
                     $m[$k][4] = $c[0][0];
                 } elseif (file_exists('public/' . $c[0][0])) {
                     $m[$k][4] = 'public/' . $c[0][0];
                 } else {
                     foreach (['vendor/phppe/*/', 'vendor/*/', 'vendor/*/*/'] as $d) {
                         if ($m[$k][4] = @glob($d . $c[0][0])[0]) {
                             break;
                         }
                     }
                 }
                 //replace image url in message
                 $new = 'cid:' . $m[$k][3];
                 $this->message = substr($this->message, 0, $c[0][1] + $diff) . $new . substr($this->message, $c[0][1] + $diff + strlen($c[0][0]));
                 $diff -= strlen($c[0][0]) - strlen($new);
             }
         }
         if (!empty($m)) {
             //! add the html part as related
             $message .= '--' . $boundary . "\n" . "Content-type: multipart/related;\n boundary=\"" . $boundary2 . "\"\n\n" . "This is a multi-part message in MIME format.\r\n--" . $boundary2 . "\n" . "Content-Type: text/html;charset=utf-8\n" . "Content-Transfer-Encoding: 8bit\n\n" . wordwrap($this->message, 78) . "\r\n";
             foreach ($m as $c) {
                 $data = empty($c[4]) ? '' : (substr($c[4], 0, 4) == 'http' ? Core::get($c[4]) : file_get_contents($c[4]));
                 if (!$data) {
                     continue;
                 }
                 //get content
                 $message .= '--' . $boundary2 . "\n" . 'Content-Type: image/' . ($c[2][0] == 'jpg' ? 'jpeg' : $c[2][0]) . "\n" . "Content-Transfer-Encoding: base64\n" . "Content-Disposition: inline\n" . 'Content-ID: <' . $c[3] . ">\n\n" . chunk_split(base64_encode($data), 78, "\n");
             }
             $message .= '--' . $boundary2 . "--\n";
         } else {
             $message .= '--' . $boundary . "\n" . "Content-type: text/html;charset=utf-8\n" . "Content-Transfer-Encoding: 8bit\n\n" . wordwrap($this->message, 78) . "\r\n";
         }
         $message .= '--' . $boundary . "--\n";
     }
     if (!empty($this->attach)) {
         $boundary = uniqid();
         $headers['Content-Type'] = "multipart/mixed;\n boundary=\"" . $boundary . '"';
         $message = "This is a multi-part message in MIME format.\r\n--" . $boundary . "\n" . $message;
         foreach ($this->attach as $attach) {
             $data = !empty($attach['data']) ? $attach['data'] : (substr($attach['file'], 0, 4) == 'http' ? Core::get($attach['file']) : file_get_contents(substr($attach['file'], 0, 6) == 'images' ? @glob('vendor/phppe/*/' . $attach['file'])[0] : $attach['file']));
             if (!$data) {
                 continue;
             }
             $message .= '--' . $boundary . "\n" . 'Content-type: ' . (!empty($attach['mime']) ? $attach['mime'] : 'application-octet-stream') . "\n" . 'Content-Disposition: attachment' . (!empty($attach['file']) ? ";\n filename=\"" . basename($attach['file']) . '"' : '') . "\n" . "Content-Transfer-Encoding: base64\n\n" . chunk_split(base64_encode($data), 78, "\n");
         }
         $message .= '--' . $boundary . "--\n";
     }
     //! flat headers
     $header = '';
     //! redirect message to a specific address (for testing)
     if (!empty(self::$forge)) {
         // @codeCoverageIgnoreStart
         $headers['To'] = self::$forge;
         $headers['Cc'] = '';
         $headers['Bcc'] = '';
         // @codeCoverageIgnoreEnd
     }
     foreach ($headers as $k => $v) {
         $header .= $k . ': ' . $v . "\r\n";
     }
     //! log that we are sending a mail
     Core::log('I', 'To: ' . $headers['To'] . ', Subject: ' . $headers['Subject'] . ', ID: ' . $id, 'email');
     //if email directory exists, save the full mime message as well for debug
     @file_put_contents('data/log/email/' . $id, 'Backend: ' . $this->via . ' ' . self::$user . ':' . self::$pass . '@' . self::$host . ':' . self::$port . "\r\n\r\n" . $header . "\r\n" . $message);
     //! *** handle transport backends ***
     switch ($this->via) {
         //! only log and possibly save message in file, do not send for real. Nothing left to do
         case 'log':
             break;
             //! return constructed mime message
         //! return constructed mime message
         case 'mime':
             return $header . "\r\n" . $message;
             break;
             //! use php's mail()
         //! use php's mail()
         case 'mail':
             $to = $headers['To'];
             $subj = $headers['Subject'];
             unset($headers['To']);
             unset($headers['Subject']);
             $header = '';
             foreach ($headers as $k => $v) {
                 $header .= $k . ': ' . $v . "\r\n";
             }
             if (!mail($to, $subj, $message, $header)) {
                 Core::log('E', 'mail() failed, To: ' . $to . ', Subject: ' . $subj . ', ID: ' . $id, 'email');
                 return false;
             }
             // @codeCoverageIgnoreStart
             break;
             //! sendmail through pipe
         //! sendmail through pipe
         case 'sendmail':
             $f = @popen('/usr/sbin/sendmail -t -i', 'w');
             if ($f) {
                 fputs($f, $header . "\r\n" . $message);
                 pclose($f);
             } else {
                 Core::log('E', 'mail() failed, To: ' . $headers['To'] . ', Subject: ' . $headers['Subject'] . ', ID: ' . $id, 'email');
                 return false;
             }
             break;
             //! this is how real programmers do it, let's speak smtp directly!
         //! this is how real programmers do it, let's speak smtp directly!
         default:
             //open socket
             $s = @fsockopen(self::$host, self::$port, $en, $es, 5);
             $l = '';
             //get welcome message
             if ($s) {
                 stream_set_timeout($s, 5);
                 $l = fgets($s, 1024);
             }
             if (!$s || substr($l, 0, 3) != '220') {
                 Core::log('E', 'connection error to ' . self::$host . ':' . self::$port . ', ' . trim($l), 'email');
                 return false;
             }
             //we silently assume we got 8BITMIME here, it's a safe assumption as of 2016
             while ($l[3] == '-') {
                 $l = fgets($s, 1024);
             }
             //greet remote
             fputs($s, 'EHLO ' . $local . "\r\n");
             $l = fgets($s, 1024);
             while ($l[3] == '-') {
                 $l = fgets($s, 1024);
             }
             //tell who are sending
             fputs($s, 'MAIL FROM: <' . array_keys($this->header['From'])[0] . ">\r\n");
             $l = fgets($s, 1024);
             if (substr($l, 0, 3) != '250') {
                 PPHPE3::log('E', 'from error: ' . trim($l), 'email');
                 return false;
             }
             //to whom
             $addresses = array_merge(array_keys($this->header['To']), array_keys($this->header['Cc']), array_keys($this->header['Bcc']));
             foreach ($addresses as $a) {
                 fputs($s, 'RCPT TO: <' . $a . ">\r\n");
                 $l = fgets($s, 1024);
                 if (substr($l, 0, 3) != '250') {
                     Core::log('E', 'recipient error: ' . trim($l), 'email');
                 }
             }
             //the message
             fputs($s, "DATA\r\n");
             $l = fgets($s, 1024);
             if (substr($l, 0, 3) != '250') {
                 Core::log('E', 'data error: ' . trim($l), 'email');
                 return false;
             }
             fputs($header . "\r\n" . str_replace(array("\n.\n", "\n.\r"), array("\n..\n", "\n..\r"), $message) . "\r\n.\r\n");
             $l = fgets($s, 1024);
             if (substr($l, 0, 3) != '250') {
                 Core::log('E', 'data send error: ' . trim($l), 'email');
                 return false;
             }
             //say bye
             fputs($s, "QUIT\r\n");
             fclose($s);
             // @codeCoverageIgnoreEnd
     }
     return true;
 }
 /**
  * @return void
  */
 public function testGetMap()
 {
     $this->assertEquals($this->classMap->getMap('catalog/product_widget_new')['catalog/product_widget_new'], 'Magento\\Catalog\\Block\\Product\\Widget\\NewWidget');
 }
Example #5
0
 public function testPercentageAmountsPassedToSetCoverageThresholdAreNotMessedWith()
 {
     $this->classMap->setCoverageThreshold(0.75);
     $this->assertEquals(0.75, $this->classMap->getCoverageThreshold());
 }
Example #6
0
 public function getClassMap($className, $module = '', $class = '')
 {
     $className = str_replace('\\', '', $className);
     if (isset($this->classMaps[$className])) {
         return $this->classMaps[$className];
     }
     if ($module == '') {
         $module = $this->location[$className]['module'];
         $class = $this->location[$className]['class'];
     } else {
         $this->location[$className]['module'] = $module;
         $this->location[$className]['class'] = $class;
     }
     $xml = $this->getMap($module, $class, $className);
     $database = (string) $xml->databaseName;
     $classMap = new ClassMap($className, $database);
     $classMap->setDatabaseName($database);
     $classMap->setTableName((string) $xml->tableName);
     if (isset($xml->extends)) {
         $classMap->setSuperClassName((string) $xml->extends);
     }
     //$config = $className::config();
     $attributes = $this->getAsArray($xml->attribute);
     foreach ($attributes as $attr) {
         $attributeMap = new AttributeMap((string) $attr->attributeName, $classMap);
         //     $converter = $this->getConverter($attr);
         if (isset($attr->attributeIndex)) {
             $attributeMap->setIndex($attr->attributeIndex);
         }
         $type = isset($attr->columnType) ? strtolower($attr->columnType) : 'string';
         if (($converterName = strtolower($attr->converter->converterName)) != '') {
             if ($converterName == 'timestampconverter') {
                 $type = 'timestamp';
             }
         }
         $attributeMap->setType($type);
         $plataformTypedAttributes = $classMap->getDb()->getPlatform()->getTypedAttributes();
         $attributeMap->setHandled(strpos($plataformTypedAttributes, $type));
         $attributeMap->setColumnName($attr->columnName ?: $attributeName);
         $attributeMap->setAlias($attr->aliasName ?: $attributeName);
         $attributeMap->setKeyType($attr->key ?: 'none');
         $attributeMap->setIdGenerator($attr->idgenerator);
         if (isset($attr->reference) && $classMap->getSuperClassMap() != NULL) {
             $referenceAttribute = $classMap->getSuperClassMap()->getAttributeMap($attributeName);
             if ($referenceAttribute) {
                 $attributeMap->setReference($referenceAttribute);
             }
         }
         $classMap->addAttributeMap($attributeMap);
     }
     $this->classMaps[$className] = $classMap;
     if (isset($xml->association)) {
         $associations = $this->getAsArray($xml->association);
         $fromClassMap = $classMap;
         foreach ($associations as $association) {
             $associationName = (string) $association->target;
             $toClass = 'business' . $association->toClassModule . $association->toClassName;
             $this->location[$toClass]['module'] = $association->toClassModule;
             $this->location[$toClass]['class'] = $association->toClassName;
             $classPath = Manager::getAppPath("modules/" . $association->toClassModule . '/models/' . $association->toClassName . '.class.php');
             Manager::addAutoloadClass($toClass, $classPath);
             $associationMap = new AssociationMap($classMap, $associationName);
             $associationMap->setToClassName($toClass);
             $associationMap->setDeleteAutomatic($association->deleteAutomatic);
             $associationMap->setSaveAutomatic($association->saveAutomatic);
             $associationMap->setRetrieveAutomatic($association->retrieveAutomatic);
             //$associationMap->setJoinAutomatic($association['joinAutomatic']);
             $autoAssociation = strtolower($className) == strtolower($toClass);
             if (!$autoAssociation) {
                 $autoAssociation = strtolower($className) == strtolower(substr($toClass, 1));
             }
             $associationMap->setAutoAssociation($autoAssociation);
             if (isset($association->indexAttribute)) {
                 $associationMap->setIndexAttribute($association->indexAttribute->indexAttributeName);
             }
             $associationMap->setCardinality($association->cardinality);
             if ($association->cardinality == 'manyToMany') {
                 $associativeClassName = 'business' . $association->associativeClassModule . $association->associativeClassName;
                 $associativeXML = $this->getMap($association->associativeClassModule, $association->associativeClassName, $associativeClassName);
                 $associationMap->setAssociativeTable((string) $associativeXML->tableName);
             } else {
                 $entries = $this->getAsArray($association->entry);
                 $inverse = $association->inverse == 'true';
                 foreach ($entries as $entry) {
                     $fromAttribute = $inverse ? $entry->toAttribute : $entry->fromAttribute;
                     $toAttribute = $inverse ? $entry->fromAttribute : $entry->toAttribute;
                     $associationMap->addKeys($fromAttribute, $toAttribute);
                 }
             }
             if (isset($association->orderAttribute)) {
                 $order = array();
                 $orderAttributes = $this->getAsArray($association->orderAttribute);
                 foreach ($orderAttributes as $orderAttr) {
                     $ascend = $orderAttr->orderAttributeDirection == 'ascend';
                     $order[] = array($orderAttr->orderAttributeName, $ascend);
                 }
                 if (count($order)) {
                     $associationMap->setOrder($order);
                 }
             }
             $fromClassMap->putAssociationMap($associationMap);
         }
     }
     return $classMap;
 }
Example #7
0
 public function getClassMap($className)
 {
     $className = strtolower(trim($className));
     if ($className[0] == '\\') {
         $className = substr($className, 1);
     }
     if ($className == '') {
         return;
     }
     if (isset($this->classMaps[$className])) {
         return $this->classMaps[$className];
     }
     $map = $this->getMap($className);
     //var_dump($map);
     $database = $map['database'];
     $classMap = new ClassMap($className, $database, $this->manager);
     $classMap->setDatabaseName($database);
     //var_dump($className . '-' . $map['table']);
     $classMap->setTableName($map['table']);
     if (isset($map['extends'])) {
         $classMap->setSuperClassName($map['extends']);
     }
     $config = $className::config();
     $attributes = $map['attributes'];
     foreach ($attributes as $attributeName => $attr) {
         $attributeMap = new AttributeMap($attributeName, $classMap);
         if (isset($attr['index'])) {
             $attributeMap->setIndex($attr['index']);
         }
         $type = isset($attr['type']) ? strtolower($attr['type']) : 'string';
         $attributeMap->setType($type);
         $plataformTypedAttributes = $classMap->getDb()->getPlatform()->getTypedAttributes();
         $attributeMap->setHandled(strpos($plataformTypedAttributes, $type) !== false);
         if ($config['converters'][$attributeName]) {
             $attributeMap->setConverter($config['converters'][$attributeName]);
         }
         $attributeMap->setColumnName($attr['column'] ?: $attributeName);
         $attributeMap->setAlias($attr['alias'] ?: $attributeName);
         $attributeMap->setKeyType($attr['key'] ?: 'none');
         $attributeMap->setIdGenerator($attr['idgenerator']);
         if ($attr['key'] == 'reference' && $classMap->getSuperClassMap() != NULL) {
             $referenceAttribute = $classMap->getSuperClassMap()->getAttributeMap($attributeName);
             if ($referenceAttribute) {
                 $attributeMap->setReference($referenceAttribute);
             }
         }
         $classMap->addAttributeMap($attributeMap);
     }
     $this->classMaps[$className] = $classMap;
     if ($referenceAttribute) {
         // set superAssociationMap
         $attributeName = $referenceAttribute->getName();
         $superClassName = $classMap->getSuperClassMap()->getName();
         $superAssociationMap = new AssociationMap($classMap, $superClassName);
         $superAssociationMap->setToClassName($superClassName);
         $superAssociationMap->setToClassMap($classMap->getSuperClassMap());
         $superAssociationMap->setCardinality('oneToOne');
         $superAssociationMap->addKeys($attributeName, $attributeName);
         $superAssociationMap->setKeysAttributes();
         $classMap->setSuperAssociationMap($superAssociationMap);
     }
     $associations = $map['associations'];
     if (isset($associations)) {
         $fromClassMap = $classMap;
         foreach ($associations as $associationName => $association) {
             $toClass = $association['toClass'];
             $associationMap = new AssociationMap($classMap, $associationName);
             $associationMap->setToClassName($toClass);
             //$associationMap->setTargetAttributeName($associationName);
             $associationMap->setDeleteAutomatic($association['deleteAutomatic']);
             $associationMap->setSaveAutomatic($association['saveAutomatic']);
             $associationMap->setRetrieveAutomatic($association['retrieveAutomatic']);
             //$associationMap->setJoinAutomatic($association['joinAutomatic']);
             $autoAssociation = strtolower($className) == strtolower($toClass);
             if (!$autoAssociation) {
                 $autoAssociation = strtolower($className) == strtolower(substr($toClass, 1));
             }
             $associationMap->setAutoAssociation($autoAssociation);
             if (isset($association['index'])) {
                 $associationMap->setIndexAttribute($association['index']);
             }
             $associationMap->setCardinality($association['cardinality']);
             if ($association['cardinality'] == 'manyToMany') {
                 $associationMap->setAssociativeTable($association['associative']);
             } else {
                 $arrayKeys = explode(',', $association['keys']);
                 foreach ($arrayKeys as $keys) {
                     $key = explode(':', $keys);
                     $associationMap->addKeys($key[0], $key[1]);
                 }
             }
             if (isset($association['order'])) {
                 $order = array();
                 $orderAttributes = explode(',', $association['order']);
                 foreach ($orderAttributes as $orderAttr) {
                     $o = explode(' ', $orderAttr);
                     $ascend = substr($o[1], 0, 3) == 'asc';
                     $order[] = array($o[0], $ascend);
                 }
                 if (count($order)) {
                     $associationMap->setOrder($order);
                 }
             }
             $fromClassMap->putAssociationMap($associationMap);
         }
     }
     return $classMap;
 }
Example #8
0
 public static function req2arr($p, $V = [], $a = 1)
 {
     if ($a) {
         $o = array();
     } else {
         $o = new \stdClass();
     }
     if (!empty(self::$v)) {
         $V += self::$v;
     }
     $R = $_REQUEST;
     foreach ($V as $K => $v) {
         if (substr($K, 0, strlen($p) + 1) == $p . '.') {
             $r = $p . '_' . substr($K, strlen($p) + 1);
             if (empty($R[$r])) {
                 $R[$r] = '';
             }
         }
     }
     foreach ($R as $k => $v) {
         if (substr($k, 0, strlen($p) + 1) == $p . '_' && $k[strlen($k) - 2] != ':') {
             $d = substr($k, strlen($p) + 1);
             $K = $p . '.' . $d;
             if (isset($V[$K])) {
                 foreach ($V[$K] as $T => $C) {
                     $t = '\\PHPPE\\AddOn\\' . $T;
                     if ((!empty($v) || $T == "check" || $T == "file") && ClassMap::has($t, 'validate')) {
                         list($r, $m) = $t::validate($K, $v, $C[1], $C[2]);
                         if (!$r && $m) {
                             $O = explode('.', $K);
                             self::error(L(ucfirst(!empty($O[1]) ? $O[1] : $O[0])) . ' ' . L($m), $K);
                         }
                     }
                     if (!empty($C[0]) && empty($v)) {
                         $v = null;
                         self::error(L(ucfirst($d)) . ' ' . L('is a required field.'), $K);
                     }
                 }
             }
             $v = $v == 'true' ? true : ($v == 'false' ? false : $v);
             if ($a) {
                 $o[$d] = $v;
             } else {
                 $o->{$d} = $v;
             }
         }
     }
     return $o;
 }
/**
 * This file aims to show you how to use this generated package.
 * In addition, the goal is to show which methods are available and the fist needed parameter(s)
 * You have to use an associative array such as:
 * - the key must be a constant beginning with WSDL_ from AbstractSoapClientbase class each generated ServiceType class extends this class
 * - the value must be the corresponding key value (each option matches a {@link http://www.php.net/manual/en/soapclient.soapclient.php} option)
 * $options = array(
 * \WsdlToPhp\PackageBase\AbstractSoapClientBase::WSDL_URL => '__WSDL_URL__',
 * \WsdlToPhp\PackageBase\AbstractSoapClientBase::WSDL_TRACE => true,
 * \WsdlToPhp\PackageBase\AbstractSoapClientBase::WSDL_LOGIN => 'you_secret_login',
 * \WsdlToPhp\PackageBase\AbstractSoapClientBase::WSDL_PASSWORD => 'you_secret_password',
 * );
 * etc....
 */
require_once __DIR__ . '/vendor/autoload.php';
/**
 * Minimal options
 */
$options = array(\WsdlToPhp\PackageBase\AbstractSoapClientBase::WSDL_URL => '__WSDL_URL__', \WsdlToPhp\PackageBase\AbstractSoapClientBase::WSDL_CLASSMAP => ClassMap::get());
/**
 * Samples for Search ServiceType
 */
$search = new \ServiceType\Search($options);
/**
 * Sample call for Search operation/method
 */
if ($search->Search(new \StructType\SearchRequest()) !== false) {
    print_r($search->getResult());
} else {
    print_r($search->getLastError());
}
Example #10
0
 protected function createClient($server, $auth, $options)
 {
     $location = 'https://' . $this->cleanServerUrl($server) . '/EWS/Exchange.asmx';
     $options = array_replace_recursive(['version' => self::VERSION_2007, 'trace' => 1, 'exceptions' => true, 'classmap' => ClassMap::getClassMap(), 'drillDownResponses' => true], $options);
     $this->server = $server;
     $this->version = $options['version'];
     $backup = libxml_disable_entity_loader(false);
     $this->soap = new NTLMSoapClient($location, $auth, dirname(__FILE__) . '/../../Resources/wsdl/services.wsdl', $options);
     libxml_disable_entity_loader($backup);
     if (isset($options['primarySmtpEmailAddress'])) {
         $this->setPrimarySmtpEmailAddress($options['primarySmtpEmailAddress']);
     }
     if (isset($options['impersonation'])) {
         $this->setPrimarySmtpEmailAddress($options['impersonation']);
     }
     $this->drillDownResponses = $options['drillDownResponses'];
 }
 private function _deleteAssociationById(PersistentObject $object, $associationName, $id, &$commands, ClassMap $classMap)
 {
     $associationMap = $classMap->getAssociationMap($associationName);
     if (is_null($associationMap)) {
         throw new EPersistentManagerException("Association name [{$associationName}] not found.");
     }
     $this->__deleteAssociationById($object, $associationMap, $id, $commands, $classMap);
 }
Example #12
0
 public function testCanDefineCustomTaskThatBundlesUpSeveralOthersInAnArray()
 {
     $classMap = new ClassMap();
     $classMap->register('dummy', '\\Gasp\\Task\\Dummy');
     $run = new Run($classMap);
     $run->task('dummy-alias', 'dummy');
     $run->task('bundle', ['dummy', 'dummy-alias']);
     $this->assertInstanceOf('\\Gasp\\Result\\Aggregate', $run->runTaskByName('bundle'));
 }