/** * Validate the plugin * * Checks that the Model is an instance of ModelInterface * * @param mixed $plugin * @throws InvalidPluginException * @return void */ public function validatePlugin($plugin) { if ($plugin instanceof ModelInterface) { return; } throw new InvalidPluginException(sprintf('Plugin of type %s is invalid; must implement %s\\Model\\ModelInterface', is_object($plugin) ? get_class($plugin) : gettype($plugin), __NAMESPACE__)); }
/** * Iterates through elements of $each and renders child nodes * * @param array $each The array or SplObjectStorage to iterated over * @param string $as The name of the iteration variable * @param string $key The name of the variable to store the current array key * @param boolean $reverse If enabled, the iterator will start with the last element and proceed reversely * @return string Rendered string * @author Sebastian Kurfürst <*****@*****.**> * @author Bastian Waidelich <*****@*****.**> * @author Robert Lemke <*****@*****.**> * @api */ public function render($each, $as, $key = '', $reverse = FALSE) { $output = ''; if ($each === NULL) { return ''; } if (is_object($each)) { if (!$each instanceof Traversable) { throw new Tx_Fluid_Core_ViewHelper_Exception('ForViewHelper only supports arrays and objects implementing Traversable interface', 1248728393); } $each = $this->convertToArray($each); } if ($reverse === TRUE) { $each = array_reverse($each); } $output = ''; foreach ($each as $keyValue => $singleElement) { $this->templateVariableContainer->add($as, $singleElement); if ($key !== '') { $this->templateVariableContainer->add($key, $keyValue); } $output .= $this->renderChildren(); $this->templateVariableContainer->remove($as); if ($key !== '') { $this->templateVariableContainer->remove($key); } } return $output; }
/** * @param string $id * @param core_libs $this */ function set($id, $lib = null) { if ($lib && is_object($lib) && !$lib instanceof Closure) { $this->_resolved($id, $lib); } return parent::set($id, $lib); }
function art_load_config() { static $moduleConfig; if (isset($moduleConfig[$GLOBALS["artdirname"]])) { return $moduleConfig[$GLOBALS["artdirname"]]; } //load_functions("config"); //$moduleConfig[$GLOBALS["artdirname"]] = mod_loadConfig($GLOBALS["artdirname"]); if (isset($GLOBALS["xoopsModule"]) && is_object($GLOBALS["xoopsModule"]) && $GLOBALS["xoopsModule"]->getVar("dirname", "n") == $GLOBALS["artdirname"]) { if (!empty($GLOBALS["xoopsModuleConfig"])) { $moduleConfig[$GLOBALS["artdirname"]] =& $GLOBALS["xoopsModuleConfig"]; } else { return null; } } else { $module_handler =& xoops_gethandler('module'); $module = $module_handler->getByDirname($GLOBALS["artdirname"]); $config_handler =& xoops_gethandler('config'); $criteria = new CriteriaCompo(new Criteria('conf_modid', $module->getVar('mid'))); $configs =& $config_handler->getConfigs($criteria); foreach (array_keys($configs) as $i) { $moduleConfig[$GLOBALS["artdirname"]][$configs[$i]->getVar('conf_name')] = $configs[$i]->getConfValueForOutput(); } unset($configs); } if ($customConfig = @(include XOOPS_ROOT_PATH . "/modules/" . $GLOBALS["artdirname"] . "/include/plugin.php")) { $moduleConfig[$GLOBALS["artdirname"]] = array_merge($moduleConfig[$GLOBALS["artdirname"]], $customConfig); } return $moduleConfig[$GLOBALS["artdirname"]]; }
/** * ArtifactFile - constructor. * * @param object The Artifact object. * @param array (all fields from artifact_file_user_vw) OR id from database. * @return boolean success. */ function ArtifactFile(&$Artifact, $data = false) { global $Language; $this->Error(); //was Artifact legit? if (!$Artifact || !is_object($Artifact)) { $this->setError('ArtifactFile: ' . $Language->getText('tracker_common_file', 'invalid')); return false; } //did ArtifactType have an error? if ($Artifact->isError()) { $this->setError('ArtifactFile: ' . $Artifact->getErrorMessage()); return false; } $this->Artifact = $Artifact; if ($data) { if (is_array($data)) { $this->data_array = $data; return true; } else { if (!$this->fetchData($data)) { return false; } else { return true; } } } }
private function varToString($var) { if (is_object($var)) { return sprintf('Object(%s)', get_class($var)); } if (is_array($var)) { $a = array(); foreach ($var as $k => $v) { $a[] = sprintf('%s => %s', $k, $this->varToString($v)); } return sprintf("Array(%s)", implode(', ', $a)); } if (is_resource($var)) { return sprintf('Resource(%s)', get_resource_type($var)); } if (null === $var) { return 'null'; } if (false === $var) { return 'false'; } if (true === $var) { return 'true'; } return (string) $var; }
public function prepare_remote_upgrade($remoteMPID = 0) { $tp = new TaskPermission(); if ($tp->canInstallPackages()) { $mri = MarketplaceRemoteItem::getByID($remoteMPID); if (!is_object($mri)) { $this->set('error', array(t('Invalid marketplace item ID.'))); return; } $local = Package::getbyHandle($mri->getHandle()); if (!is_object($local) || $local->isPackageInstalled() == false) { $this->set('error', array(Package::E_PACKAGE_NOT_FOUND)); return; } $r = $mri->downloadUpdate(); if ($r != false) { if (!is_array($r)) { $this->set('error', array($r)); } else { $errors = Package::mapError($r); $this->set('error', $errors); } } else { $this->redirect('/dashboard/extend/update', 'do_update', $mri->getHandle()); } } }
/** * */ public function refine(&$pa_destination_data, $pa_group, $pa_item, $pa_source_data, $pa_options = null) { $o_log = isset($pa_options['log']) && is_object($pa_options['log']) ? $pa_options['log'] : null; // Set place hierarchy if ($vs_hierarchy = $pa_item['settings']['placeSplitter_placeHierarchy']) { $vn_hierarchy_id = caGetListItemID('place_hierarchies', $vs_hierarchy); } else { // Default to first place hierarchy $t_list = new ca_lists(); $va_hierarchy_ids = $t_list->getItemsForList('place_hierarchies', array('idsOnly' => true)); $vn_hierarchy_id = array_shift($va_hierarchy_ids); } if (!$vn_hierarchy_id) { if ($o_log) { $o_log->logError(_t('[placeSplitterRefinery] No place hierarchies are defined')); } return array(); } $pa_options['hierarchyID'] = $vn_hierarchy_id; $t_place = new ca_places(); if ($t_place->load(array('parent_id' => null, 'hierarchy_id' => $vn_hierarchy_id))) { $pa_options['defaultParentID'] = $t_place->getPrimaryKey(); } return caGenericImportSplitter('placeSplitter', 'place', 'ca_places', $this, $pa_destination_data, $pa_group, $pa_item, $pa_source_data, $pa_options); }
/** * Ajouter un champ * * @param $type type de champ à ajouter (correspond au nom de l'objet réprésentant le champ) * @param $name nom du champ (doit être unique) * @param $value valeur par défaut * * @return obj (retourne l'objet représentant le champ créé) */ public function add($type, $name = '', $value = '', $label = '') { if (is_object($type)) { if (isset($this->fields[$type->getName()])) { trigger_error('Un champ nommé « ' . $type->getName() . ' » existe déjà.', E_USER_ERROR); } $this->fields[$type->getName()] = $type; } else { if (empty($name)) { trigger_error('L\'argument name est nécessaire pour la création du champ.', E_USER_ERROR); } if (isset($this->fields[$name])) { trigger_error('Un champ nommé « ' . $name . ' » existe déjà.', E_USER_ERROR); } else { $field = 'Field_' . $type; if ($field == 'Field_SubmitButton') { $o_Field = new $field($name); } else { $o_Field = new $field($name, $value, $label); } $o_Field->setForm($this); $this->fields[$name] = $o_Field; return $o_Field; } } }
/** * Process * * @param mixed $value * @param array $options * * @return string|null */ public function process($value, array $options = array()) { if ($value === null) { return; } if (!class_exists('\\libphonenumber\\PhoneNumberUtil')) { throw new \RuntimeException('Library for phone checking not found'); } if (is_object($value) || is_resource($value) || is_array($value)) { $this->throwException($options, 'error'); } try { $phone = $this->getPhone($value, $options, $is_toll_free); } catch (\libphonenumber\NumberParseException $e) { $this->throwException($options, 'error'); } $util = \libphonenumber\PhoneNumberUtil::getInstance(); if (!$util->isValidNumber($phone)) { $this->throwException($options, 'error'); } if ($is_toll_free) { return $phone->getNationalNumber(); } return (string) $util->format($phone, $this->getDefaultPhoneFormat($options)); }
protected function isGranted($attribute, $object, $user = null) { if (!$user) { $user = $this->tokenStorage->getToken()->getUser(); } if (!is_object($user)) { return false; } if (in_array('ROLE_ADMINISTRATOR', $user->getRoles())) { return true; } if (!in_array('ROLE_USER', $user->getRoles())) { return false; } if (in_array($attribute, [self::ATTRIBUTE_VIEW, self::ATTRIBUTE_CREATE])) { return true; } /** * @var Subcontractor $object */ if ($attribute == self::ATTRIBUTE_EDIT) { return $object->getCreatedBy() && $user->getId() == $object->getCreatedBy()->getId() || in_array('ROLE_SUBCONTRACTOR_MANAGER', $user->getRoles()); } return false; }
/** * Creates a new validation value for a validation set. * * @param string|IValidator $validator The validator to build be it a class name (fully qualified) * or a dummy validator object. * @param mixed ...$params The parameters to the validator. To use a field from the validated * object, set these as ValidationKey objects. */ public function __construct($validator) { if (is_object($validator)) { if (!$validator instanceof IValidator) { throw new \InvalidArgumentException(Intl\GetText::_d('Flikore.Validator', 'The validator object must be a implementation of IValidator')); } else { $this->validator = get_class($validator); } } elseif (is_string($validator)) { if (!is_subclass_of($validator, 'Flikore\\Validator\\Interfaces\\IValidator')) { throw new \InvalidArgumentException(Intl\GetText::_d('Flikore.Validator', 'The validator object must be a implementation of IValidator')); } else { $this->validator = $validator; } } else { throw new \InvalidArgumentException(Intl\GetText::_d('Flikore.Validator', 'The validator object must be a implementation of IValidator')); } $params = func_get_args(); array_shift($params); foreach ($params as $arg) { if ($arg instanceof ValidationKey) { $this->fields[] = $arg->getKey(); } } $this->args = $params; }
public function import(\SimpleXMLElement $sx) { $em = \Database::connection()->getEntityManager(); $em->getClassMetadata('Concrete\\Core\\Entity\\Express\\Entity')->setIdGenerator(new \Doctrine\ORM\Id\AssignedGenerator()); if (isset($sx->expressentities)) { foreach ($sx->expressentities->entity as $entityNode) { $entity = $em->find('Concrete\\Core\\Entity\\Express\\Entity', (string) $entityNode['id']); if (!is_object($entity)) { $entity = new Entity(); $entity->setId((string) $entityNode['id']); } $entity->setPluralHandle((string) $entityNode['plural_handle']); $entity->setHandle((string) $entityNode['handle']); $entity->setDescription((string) $entityNode['description']); $entity->setName((string) $entityNode['name']); if ((string) $entityNode['include_in_public_list'] == '') { $entity->setIncludeInPublicList(false); } $entity->setHandle((string) $entityNode['handle']); $tree = ExpressEntryResults::get(); $node = $tree->getNodeByDisplayPath((string) $entityNode['results-folder']); $node = \Concrete\Core\Tree\Node\Type\ExpressEntryResults::add((string) $entityNode['name'], $node); $entity->setEntityResultsNodeId($node->getTreeNodeID()); $indexer = $entity->getAttributeKeyCategory()->getSearchIndexer(); if (is_object($indexer)) { $indexer->createRepository($entity->getAttributeKeyCategory()); } $em->persist($entity); } } $em->flush(); $em->getClassMetadata('Concrete\\Core\\Entity\\Express\\Entity')->setIdGenerator(new UuidGenerator()); }
function sectioned_page_output() { wp_enqueue_script('sticky', WP_PLUGIN_URL . '/' . plugin_dir_path('msd-specialty-pages/msd-specialty-pages.php') . '/lib/js/jquery.sticky.js', array('jquery'), FALSE, TRUE); global $post, $subtitle_metabox, $sectioned_page_metabox, $nav_ids; $i = 0; $meta = $sectioned_page_metabox->the_meta(); if (is_object($sectioned_page_metabox)) { while ($sectioned_page_metabox->have_fields('sections')) { $layout = $sectioned_page_metabox->get_the_value('layout'); switch ($layout) { case "three-boxes": break; default: $sections[] = self::default_output($meta['sections'][$i], $i); break; } $i++; } //close while print '<div class="sectioned-page-wrapper">'; print implode("\n", $sections); print '</div>'; } //clsoe if }
public function setUp() { $this->array = array(); // create an instance $this->instance = new ArrayFileStore($this->array); $this->assertTrue(is_object($this->instance)); }
/** * Return the IMP_Imap instance for a given mailbox/identifier. * * @param string $id Mailbox/identifier. * * @return IMP_Imap IMP_Imap object. */ public function create($id = null) { global $registry, $session; if (!is_null($id) && $registry->getAuth() !== false && ($base = $this->_injector->getInstance('IMP_Remote')->getRemoteById($id))) { $id = strval($base); } else { $base = null; $id = self::BASE_OB; } if (!isset($this->_instance[$id])) { $ob = null; try { $ob = $session->get('imp', 'imap_ob/' . $id); } catch (Exception $e) { // This indicates an unserialize() error. This is fatal, so // logout. $failure = new Horde_Exception_AuthenticationFailure('Cached IMP session data has become invalid; expiring session.', Horde_Auth::REASON_SESSION); $failure->application = 'imp'; throw $failure; } if (!is_object($ob)) { $ob = is_null($base) ? new IMP_Imap($id) : new IMP_Imap_Remote($id); } /* Attach IMAP alert handler. */ if ($c_ob = $ob->client_ob) { $c_ob->alerts_ob->attach($this); } $this->_instance[$id] = $ob; } return $this->_instance[$id]; }
/** * validate a string * * @param mixed $str the value to evaluate as a string * * @throws \InvalidArgumentException if the submitted data can not be converted to string * * @return string */ protected function validateString($str) { if (is_object($str) && method_exists($str, '__toString') || is_string($str)) { return trim($str); } throw new InvalidArgumentException('The data received is not OR can not be converted into a string'); }
function MetaType($t, $len = -1) { if (is_object($t)) { $fieldobj = $t; $t = $fieldobj->type; $len = $fieldobj->max_length; } switch (strtoupper($t)) { case 'C': if ($len <= $this->blobSize) { return 'C'; } case 'M': return 'X'; case 'D': return 'D'; case 'T': return 'T'; case 'L': return 'L'; case 'I': return 'I'; default: return 'N'; } }
/** * Class constructor */ function __construct($options = array()) { //Initialise the array $this->_pathway = array(); $menu =& JSite::getMenu(); if ($item = $menu->getActive()) { $menus = $menu->getMenu(); $home = $menu->getDefault(); if (is_object($home) && $item->id != $home->id) { foreach ($item->tree as $menupath) { $url = ''; $link = $menu->getItem($menupath); switch ($link->type) { case 'menulink': case 'url': $url = $link->link; break; case 'separator': $url = null; break; default: $url = 'index.php?Itemid=' . $link->id; } $this->addItem($menus[$menupath]->name, $url); } // end foreach } } // end if getActive }
function plgAcymailingContentplugin(&$subject, $config) { parent::__construct($subject, $config); if (!isset($this->params)) { $plugin = JPluginHelper::getPlugin('acymailing', 'contentplugin'); $this->params = new acyParameter($plugin->params); } $this->paramsContent = JComponentHelper::getParams('com_content'); JPluginHelper::importPlugin('content'); $this->dispatcherContent = JDispatcher::getInstance(); $excludedHandlers = array('plgContentEmailCloak', 'pluginImageShow'); $excludedNames = array('system' => array('SEOGenerator', 'SEOSimple'), 'content' => array('webeecomment', 'highslide', 'smartresizer', 'phocagallery')); $excludedType = array_keys($excludedNames); if (!ACYMAILING_J16) { foreach ($this->dispatcherContent->_observers as $id => $observer) { if (is_array($observer) and in_array($observer['handler'], $excludedHandlers)) { $this->dispatcherContent->_observers[$id]['event'] = ''; } elseif (is_object($observer)) { if (in_array($observer->_type, $excludedType) and in_array($observer->_name, $excludedNames[$observer->_type])) { $this->dispatcherContent->_observers[$id] = null; } } } } if (!class_exists('JSite')) { include_once ACYMAILING_ROOT . 'includes' . DS . 'application.php'; } }
function content_56655ccb038d51_05727181($_smarty_tpl) { ?> <div class="tree-actions pull-right"> <?php if (isset($_smarty_tpl->tpl_vars['actions']->value)) { ?> <?php $_smarty_tpl->tpl_vars['action'] = new Smarty_Variable(); $_smarty_tpl->tpl_vars['action']->_loop = false; $_from = $_smarty_tpl->tpl_vars['actions']->value; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array'); } foreach ($_from as $_smarty_tpl->tpl_vars['action']->key => $_smarty_tpl->tpl_vars['action']->value) { $_smarty_tpl->tpl_vars['action']->_loop = true; ?> <?php echo $_smarty_tpl->tpl_vars['action']->value->render(); ?> <?php } ?> <?php } ?> </div><?php }
/** * search user/corporation or alliance by name * @param $f3 * @param $params */ public function search($f3, $params) { $accessData = []; if (array_key_exists('arg1', $params) && array_key_exists('arg2', $params)) { $searchType = strtolower($params['arg1']); $searchToken = strtolower($params['arg2']); $accessModel = null; switch ($searchType) { case 'user': $accessModel = Model\BasicModel::getNew('UserModel'); break; case 'corporation': $accessModel = Model\BasicModel::getNew('CorporationModel'); break; case 'alliance': $accessModel = Model\BasicModel::getNew('AllianceModel'); break; } if (is_object($accessModel)) { // find "active" entries that have their "sharing" option activated $accessList = $accessModel->find(array("LOWER(name) LIKE :token AND " . "active = 1 AND " . "shared = 1 ", ':token' => '%' . $searchToken . '%')); if ($accessList) { foreach ($accessList as $accessObject) { $accessData[] = $accessObject->getData(); } } } } echo json_encode($accessData); }
/** * Test deletion of DataObjects * - Deleting using delete() on the DataObject * - Deleting using DataObject::delete_by_id() */ function testDelete() { // Test deleting using delete() on the DataObject // Get the first page $page = $this->objFromFixture('Page', 'page1'); $pageID = $page->ID; // Check the page exists before deleting $this->assertTrue(is_object($page) && $page->exists()); // Delete the page $page->delete(); // Check that page does not exist after deleting $page = DataObject::get_by_id('Page', $pageID); $this->assertTrue(!$page || !$page->exists()); // Test deleting using DataObject::delete_by_id() // Get the second page $page2 = $this->objFromFixture('Page', 'page2'); $page2ID = $page2->ID; // Check the page exists before deleting $this->assertTrue(is_object($page2) && $page2->exists()); // Delete the page DataObject::delete_by_id('Page', $page2->ID); // Check that page does not exist after deleting $page2 = DataObject::get_by_id('Page', $page2ID); $this->assertTrue(!$page2 || !$page2->exists()); }
/** * Constructor * * @param Adapter $adapter * @param array $data * @return void */ public function __construct($adapter, $data = null) { if (!$adapter instanceof Zend_Cloud_Infrastructure_Adapter) { #require_once 'Zend/Cloud/Infrastructure/Exception.php'; throw new Zend_Cloud_Infrastructure_Exception("You must pass a Zend_Cloud_Infrastructure_Adapter instance"); } if (is_object($data)) { if (method_exists($data, 'toArray')) { $data = $data->toArray(); } elseif ($data instanceof Traversable) { $data = iterator_to_array($data); } } if (empty($data) || !is_array($data)) { #require_once 'Zend/Cloud/Infrastructure/Exception.php'; throw new Zend_Cloud_Infrastructure_Exception("You must pass an array of parameters"); } foreach ($this->attributeRequired as $key) { if (empty($data[$key])) { #require_once 'Zend/Cloud/Infrastructure/Exception.php'; throw new Zend_Cloud_Infrastructure_Exception(sprintf('The param "%s" is a required param for %s', $key, __CLASS__)); } } $this->adapter = $adapter; $this->attributes = $data; }
/** * Constructor. * * @param mixed $value The value to mark as safe */ public function __construct($value) { $this->value = $value; if (is_array($value) || is_object($value)) { parent::__construct($value); } }
public function submit($arLayoutID) { if ($this->validateAction()) { $arLayout = AreaLayout::getByID($arLayoutID); if (!is_object($arLayout)) { throw new Exception(t('Invalid layout object.')); } if ($_POST['arLayoutPresetID'] == '-1') { UserPreset::add($arLayout, $_POST['arLayoutPresetName']); } else { $existingPreset = UserPreset::getByID($_POST['arLayoutPresetID']); if (is_object($existingPreset)) { $existingPreset->updateName($_POST['arLayoutPresetName']); $existingPreset->updateAreaLayoutObject($arLayout); } } $pr = new EditResponse(); if ($existingPreset) { $pr->setMessage(t('Area layout preset updated successfully.')); } else { $pr->setMessage(t('Area layout preset saved successfully.')); } $pr->outputJSON(); } }
function load($tpl_view, $body_view = null, $data = null) { if (!is_null($body_view)) { if (file_exists(APPPATH . 'views/' . $tpl_view . '/' . $body_view)) { $body_view_path = $tpl_view . '/' . $body_view; } else { if (file_exists(APPPATH . 'views/' . $tpl_view . '/' . $body_view . '.php')) { $body_view_path = $tpl_view . '/' . $body_view . '.php'; } else { if (file_exists(APPPATH . 'views/' . $body_view)) { $body_view_path = $body_view; } else { if (file_exists(APPPATH . 'views/' . $body_view . '.php')) { $body_view_path = $body_view . '.php'; } else { show_error('Unable to load the requested file: ' . $tpl_name . '/' . $view_name . '.php'); } } } } $body = $this->ci->load->view($body_view_path, $data, TRUE); if (is_null($data)) { $data = array('body' => $body); } else { if (is_array($data)) { $data['body'] = $body; } else { if (is_object($data)) { $data->body = $body; } } } } $this->ci->load->view('templates/' . $tpl_view, $data); }
public static function create($isoLang = 'pt_BR') { $xmlDoc = new DOMDocument('1.0', 'utf-8'); $xmlDoc->formatOutput = true; $culture = $xmlDoc->createElement($isoLang); $culture = $xmlDoc->appendChild($culture); $criteria = new Criteria(); $criteria->add(TagI18n::TABLE . '.' . TagI18n::ISOLANG, $isoLang); $objTagI18n = new TagI18nPeer(); $arrayObjTagI18n = $objTagI18n->doSelect($criteria); if (!is_object($arrayObjTagI18n) && count($arrayObjTagI18n == 0)) { $log = new Log(); $log->setLog(__FILE__, 'There are no tags with that language ' . $isoLang, true); throw new Exception('There are no tags with that language ' . $isoLang); } foreach ($arrayObjTagI18n as $objTagI18nPeer) { $item = $xmlDoc->createElement('item'); $item->setAttribute('idTagI18n', $objTagI18nPeer->getIdTagI18n()); $item = $culture->appendChild($item); $title = $xmlDoc->createElement('tag', utf8_encode($objTagI18nPeer->getTag())); $title = $item->appendChild($title); $link = $xmlDoc->createElement('i18n', utf8_encode($objTagI18nPeer->getTranslate())); $link = $item->appendChild($link); } //header("Content-type:application/xml; charset=utf-8"); $file = PATH . PATH_I18N . $isoLang . '.xml'; try { file_put_contents($file, $xmlDoc->saveXML()); } catch (Exception $e) { $log = new Log(); $log->setLog(__FILE__, 'Unable to write the XML file I18n ' . $e->getMessage(), true); } return true; }
public function transaction($querie, $commit = FALSE) { try { if (is_object($querie)) { $data = $querie->execute(); $lastId = $this->db->lastInsertId(); } else { return false; } if ($commit) { try { $this->db->commit(); return true; } catch (PDOException $e) { die($e->getMessage()); } } else { return $lastId; } } catch (PDOException $e) { try { $this->db->rollBack(); die($e->getMessage()); return false; } catch (PDOException $e) { die($e->getMessage()); return false; } } }
/** * Make an api request * * @param string $resource * @param array $params * @param string $method */ public function call($resource, $params = array()) { $queryString = 'access_token=' . $this->getAccessToken(); if (!empty($params) && is_array($params)) { $queryString .= http_build_query($params); } $requestUrl = self::API_URL . $resource . '/?' . $queryString; $curl = curl_init(); $curl_options = array(CURLOPT_RETURNTRANSFER => 1, CURLOPT_URL => $requestUrl, CURLOPT_TIMEOUT => 30, CURLOPT_HTTPHEADER => array('Accept: application/json', 'appid: nike')); curl_setopt_array($curl, $curl_options); $response = curl_exec($curl); $curl_info = curl_getinfo($curl); //@todo test for curl error if ($response === FALSE) { throw new Exception(curl_error($curl), curl_errno($curl)); } curl_close($curl); //@todo test for any non 200 response if ($curl_info['http_code'] != 200) { throw new Exception("Response: Bad response - HTTP Code:" . $curl_info['http_code']); } $jsonArray = json_decode($response); if (!is_object($jsonArray)) { throw new Exception("Response: Response was not a valid response"); } return $jsonArray; }