public function __construct($id = false, $table = null, $ds = null) { parent::__construct($id, $table, $ds); $datasource = ConnectionManager::getDataSource($this->useDbConfig); //$datasource = ConnectionManager::loadDataSource('SalesforceSource'); if ($datasource->_baseConfig['dynamic_mode']) { $this->_schema = $datasource->getSchema($this->name); } else { if (!empty($datasource->_baseConfig['my_wsdl'])) { $wsdl = APP . "Config" . DS . $datasource->_baseConfig['my_wsdl']; } else { $wsdl = App::Path('Vendor')[0] . 'salesforce/soapclient/' . $datasource->_baseConfig['standard_wsdl']; } $database_fields = Xml::toArray(Xml::build($wsdl)); $schemas = $database_fields['definitions']['types']['schema'][0]['complexType']; $this_wsdl_schema = array(); foreach ($schemas as $schema) { if ($schema['@name'] == $this->name) { $this_wsdl_schema = $schema['complexContent']['extension']['sequence']['element']; break; } } $names = Hash::extract($this_wsdl_schema, '{n}.@name'); $types = Hash::extract($this_wsdl_schema, '{n}.@type'); $new_array = array('Id' => array('type' => 'string', 'length' => 16)); $n = 0; $type_name = ""; foreach ($names as $name) { if (substr($types[$n], 0, 3) != "ens") { //we dont want type of ens if (substr($types[$n], 4) != "QueryResult") { //Or this if (substr($types[$n], 4) == "int") { $type_name = "integer"; } elseif (substr($types[$n], 4) == "boolean") { $type_name = "boolean"; } elseif (substr($types[$n], 4) == "dateTime" || substr($types[$n], 4) == "date") { $type_name = "datetime"; } else { $type_name = "string"; } $new_array[$name] = array('type' => $type_name, 'length' => 255); } } $n++; } $this->_schema = $new_array; } return true; }
/** * Update components. * * - Make components that extend Object to extend Component. * * @return void */ public function components() { $this->_paths = App::Path('Controller/Component'); if (!empty($this->params['plugin'])) { $this->_paths = App::Path('Controller/Component', $this->params['plugin']); } $patterns = array(array('*Component extends Object to *Component extends Component', '/([a-zA-Z]*Component extends) Object/', '\\1 Component')); $this->_filesRegexpUpdate($patterns); }
/** * Use WSDL for basic fields first of all * passes the salesforce credentals for login * @return boolean True on success, false on failure */ public function connect() { //Vendor loading seems to be picky using App::import require_once App::Path('Vendor')[0] . 'salesforce/soapclient/SforceEnterpriseClient.php'; if (empty($this->config['my_wsdl'])) { $wsdl = App::Path('Vendor')[0] . 'salesforce/soapclient/' . $this->config['standard_wsdl']; } else { $wsdl = APP . "Config" . DS . $this->config['my_wsdl']; } $mySforceConnection = new SforceEnterpriseClient(); //Dont forget to Change your API version in here! $mySoapClient = $mySforceConnection->createConnection($wsdl); $sflogin = (array) Cache::read('salesforce_login', 'short'); if (!empty($sflogin['sessionId'])) { $mySforceConnection->setSessionHeader($sflogin['sessionId']); $mySforceConnection->setEndPoint($sflogin['serverUrl']); } else { $mylogin = $mySforceConnection->login($this->config['username'], $this->config['password']); $sflogin = array('sessionId' => $mylogin->sessionId, 'serverUrl' => $mylogin->serverUrl); Cache::write('salesforce_login', $sflogin, 'short'); } $this->client = $mySforceConnection; $this->connected = true; return $this->connected; }