Выборка данных из AmoCRM в зависимости от типов данных. (contacts, leads, notes)
@return Object
182976
public function listData($query = false, $type = self::TYPE_LEADS)
	{
		$type 		= $this->amoType($type);
		if ($query != false) {
			$query = '?' . http_build_query($query);
		}
		$link			= 'https://' . $this->subdomain . '.amocrm.ru/private/api/v2/json/' . $type . '/list'. $query;
		$postFields = false;
		$result 		= $this->useCurl($link, $postFields, self::HTTP_HEADER);
		return json_decode($result);
	}
1213583
public function Form()
    {
        $crumbs = $this->Breadcrumbs();
        
        if ($crumbs && $crumbs->count()>=2) {
            $one_level_up = $crumbs->offsetGet($crumbs->count()-2);
        }
        
        $record_ids = "";
        $query_string = "";
        $recordList = $this->getRecordIDList();
        
        foreach ($this->getRecordIDList() as $id) {
            $record_ids .= $id . ',';
            $query_string .= "records[]={$id}&";
        }
        
        // Cut off the last 2 parts of the string
        $record_ids = substr($record_ids, 0, -1);
        $query_string = substr($query_string, 0, -1);
        
        $form = new Form(
            $this,
            'Form',
            $fields = FieldList::create(
                HiddenField::create("RecordIDs", "", $record_ids),
                TagField::create(
                    'Tags',
                    null,
                    ContactTag::get()
                )->setDescription(_t(
                    "Contacts.TagDescription",
                    "List of tags related to this contact, seperated by a comma."
                ))->setShouldLazyLoad(true)
            ),
            $actions = FieldList::create(
                FormAction::create('doAddTags', _t("Contacts.Add", 'Add'))
                    ->setAttribute('id', 'bulkEditingSaveBtn')
                    ->addExtraClass('btn btn-success')
                    ->setAttribute('data-icon', 'accept')
                    ->setUseButtonTag(true),
                    
                FormAction::create('Cancel', _t('GRIDFIELD_BULKMANAGER_EDIT_HANDLER.CANCEL_BTN_LABEL', 'Cancel'))
                    ->setAttribute('id', 'bulkEditingUpdateCancelBtn')
                    ->addExtraClass('btn btn-danger cms-panel-link')
                    ->setAttribute('data-icon', 'decline')
                    ->setAttribute('href', $one_level_up->Link)
                    ->setUseButtonTag(true)
                    ->setAttribute('src', '')
            )
        );
        
        if ($crumbs && $crumbs->count() >= 2) {
            $form->Backlink = $one_level_up->Link;
        }
        
        // override form action URL back to bulkEditForm
        // and add record ids GET var
        $form->setFormAction(
            $this->Link('Form?records[]='.implode('&', $recordList))
        );

        return $form;
    }
1043357
public static function restore()
	{
		$dataForms = self::get();

		if ($dataForms != null)
		{
			// вставляем скрипт десериализации
			$script = self::insertScript();

			foreach ($dataForms as $idForm => $dataForm)
			{
				$script .= "
					<script language=\"javascript\" type=\"text/javascript\">
					$().ready(function()
					{
						$('#{$idForm}').populate({$dataForm});
					});
					</script>
				";
				return $script;
			}
		}
	}
1168290
protected function getObject()
	{
		if( !isset( $this->object ) )
		{
			$siteid = $this->context->getLocale()->getSiteId();
			$conf = array( 'siteid' => $this->context->getConfig()->get( 'madmin/cache/prefix' ) . $siteid );
			$this->object = \Aimeos\MW\Cache\Factory::create( 'Flow', $conf, $this->cache );
		}

		return $this->object;
	}
1340434
private function newCard() {return dfc($this, function() {
		$m = $this->m(); /** @var Method $m */
		$isCard = $m->isCard(); /** @var bool $isCard */
		df_assert(!$isCard || $this->tokenIsNew());
		$customer = null; /** @var object|null $customer */
		$cardId = null; /** @var string $cardId */
		$fc = FCustomer::s($m); /** @var FCustomer $fc */
		if ($customerId = $this->customerIdSaved() /** @var string $customerId */) {
			// 2016-08-23 https://stripe.com/docs/api/php#retrieve_customer
			// 2017-02-10 Зарегистрированный в ПС покупатель с незарегистрированной в ПС картой.
			// 2017-07-16 We ensure here that the customer with the ID given is really exist in the PSP.
			$customer = $fc->get($customerId);
			// 2017-02-24
			// We can get here, for example, if the store's administrator has switched
			// his Stripe account in the extension's settings: https://mage2.pro/t/3337
			if (!$customer) {
				df_ci_save($this->m(), null);
				$customerId = null;
			}
		}
		if ($customer) {
			if ($isCard) {
				// 2016-08-23
				// Зарегистрированный в ПС покупатель с незарегистрированной в ПС картой.
				// Сохраняем её: https://stripe.com/docs/api#create_card
				/**
				 * 2017-07-16
				 * If a PSP does not support the «cardAdd» operation for a token (like Moip and Spryng),
				 * then the facade should just return the token.
				 * @see \Dfe\Moip\Facade\Customer::cardAdd()
				 * https://github.com/mage2pro/moip/blob/0.7.2/Facade/Customer.php#L37-L55
				 * @see \Dfe\Spryng\Facade\Customer::cardAdd()
				 * https://github.com/mage2pro/spryng/blob/1.1.10/Facade/Customer.php#L18-L27
				 */
				$cardId = $fc->cardAdd($customer, $this->token());
				df_assert_sne($cardId);
			}
		}
		else {
			// 2017-06-11 It registers the customer in the PSP.
			// 2016-08-22 Stripe: https://stripe.com/docs/api/php#create_customer
			// 2016-11-15 Omise: https://www.omise.co/customers-api#customers-create
			// 2017-02-11 Paymill: https://developers.paymill.com/API/index#create-new-client-
			$customer = $fc->create(Reg::request($m));
			df_ci_save($this->m(), $customerId = $fc->id($customer));
			if ($isCard) {
				// 2017-02-18 Вторая часть условия — для ПС (Spryng), которые не поддерживают сохранение карт.
				$cardId =
					// 2017-10-10 Square supports a card saving, but requires an additional step to do it.
					$fc->addCardInASeparateStepForNewCustomers()
					? $fc->cardAdd($customer, $this->token())
					// 2017-07-16
					// Moip supports a card saving, but does not allow to do it on the customer's registration.
					// The card is saved in Moip only on a payment request.
					// https://github.com/mage2pro/moip/blob/0.7.0/P/Reg.php#L24-L29
					// https://github.com/mage2pro/moip/blob/0.7.0/T/CaseT/Customer.php#L94-#L106
					: ($fc->cardIdForJustCreated($customer) ?: $this->token())
				;
			}
		}
		if ($cardId) {
			Token::exchangedSet($this->m()->getCode(), $cardId);
		}
		return [$customerId, $cardId];
	});}
1124305
public function get()
    {
        // Pre-populating the 'calendardata' is optional, if we don't have it
        // already we fetch it from the backend.
        if (!isset($this->objectData['calendardata'])) {
            $this->objectData = $this->caldavBackend->getSchedulingObject($this->objectData['principaluri'], $this->objectData['uri']);
        }

        return $this->objectData['calendardata'];
    }
337541
public function &GetActiveSearchObject()
    {
        if (is_null($this->oActiveSearchCache) && array_key_exists(self::SESSION_ACTIVE_SEARCH_CACHE_ID, $_SESSION)) {
            $this->oActiveSearchCache = unserialize(base64_decode($_SESSION[self::SESSION_ACTIVE_SEARCH_CACHE_ID]));
            //        $this->oActiveSearchCache = TdbShopSearchCache::GetNewInstance();
            //        if (!$this->oActiveSearchCache->Load($_SESSION[self::SESSION_ACTIVE_SEARCH_CACHE_ID])) $this->oActiveSearchCache = null;
        }

        return $this->oActiveSearchCache;
    }
1205317
public function toObject()
    {
        $obj = new stdClass();

        if (! empty($this->attributes)) {
            foreach ($this->attributes as $key => $value) {
                $obj->$key = $value;
            }
        }

        return $obj;
    }
598316
function createContact() {
    $cnt = count( $this->contact );
    if( 0 >= $cnt )
      return;
    $output = null;
    foreach( $this->contact as $contact ) {
      $attributes = $this->_createParams( $contact['params'], array( 'ALTREP', 'LANGUAGE' ));
      $content    = $this->_strrep( $contact['value'] );
      $output    .= $this->_createElement( 'CONTACT', $attributes, $content );
    }
    return $output;
  }
1328741
public function Form()
    {
        $crumbs = $this->Breadcrumbs();
        
        if ($crumbs && $crumbs->count()>=2) {
            $one_level_up = $crumbs->offsetGet($crumbs->count()-2);
        }
        
        $record_ids = "";
        $query_string = "";
        $recordList = $this->getRecordIDList();
        
        foreach ($this->getRecordIDList() as $id) {
            $record_ids .= $id . ',';
            $query_string .= "records[]={$id}&";
        }
        
        // Cut off the last 2 parts of the string
        $record_ids = substr($record_ids, 0, -1);
        $query_string = substr($query_string, 0, -1);
        
        $form = new Form(
            $this,
            'Form',
            $fields = FieldList::create(
                HiddenField::create("RecordIDs", "", $record_ids),
                DropdownField::create(
                    "ContactListID",
                    _t("Contacts.ChooseList", "Choose a list"),
                    ContactList::get()->map()
                )->setEmptyString(_t("Contacts.SelectList", "Select a List"))
            ),
            $actions = FieldList::create(
                FormAction::create('doAddToList', _t("Contacts.Add", 'Add'))
                    ->setAttribute('id', 'bulkEditingSaveBtn')
                    ->addExtraClass('btn btn-success')
                    ->setAttribute('data-icon', 'accept')
                    ->setUseButtonTag(true),
                    
                FormAction::create('Cancel', _t('GRIDFIELD_BULKMANAGER_EDIT_HANDLER.CANCEL_BTN_LABEL', 'Cancel'))
                    ->setAttribute('id', 'bulkEditingUpdateCancelBtn')
                    ->addExtraClass('btn btn-danger cms-panel-link')
                    ->setAttribute('data-icon', 'decline')
                    ->setAttribute('href', $one_level_up->Link)
                    ->setUseButtonTag(true)
                    ->setAttribute('src', '')
            )
        );
        
        if ($crumbs && $crumbs->count() >= 2) {
            $form->Backlink = $one_level_up->Link;
        }
        
        // override form action URL back to bulkEditForm
        // and add record ids GET var
        $form->setFormAction(
            $this->Link('Form?records[]='.implode('&', $recordList))
        );

        return $form;
    }
808804
public function getBaseObject()
    {
        if (!$this->_oBaseObject) {
            $this->_oBaseObject = oxNew($this->_sObjectsInListName);
            $this->_oBaseObject->setInList();
            $this->_oBaseObject->init($this->_sCoreTable);
        }

        return $this->_oBaseObject;
    }
381165
private function getCacheModel()
    {
        if (!$this->cacheModel) {
            /* @var \MauticPlugin\MauticContactClientBundle\Model\Cache $cacheModel */
            $this->cacheModel = $this->getContainer()->get('mautic.contactclient.model.cache');
            $this->cacheModel->setContact($this->contact);
            $this->cacheModel->setContactClient($this->contactClient);
            $this->cacheModel->setDateSend($this->dateSend);
        }

        return $this->cacheModel;
    }
435816
public function getActShopCurrencyObject()
    {
        if ($this->_oActCurrencyObject === null) {
            $cur = $this->getShopCurrency();
            $currencies = $this->getCurrencyArray();
            if (!isset($currencies[$cur])) {
                $this->_oActCurrencyObject = reset($currencies); // reset() returns the first element
            } else {
                $this->_oActCurrencyObject = $currencies[$cur];
            }
        }

        return $this->_oActCurrencyObject;
    }
1240592
public function current()
    {
        $k = key($this->ids);
        if (null === $k) {
            return false;
        }

        if (count($this->ids) == 1) {
            return $this;
        }

        if (!isset($this->_ich[$k])) {
            $this->_ich[$k] = new self($this->doc, array($k => $this->ids[$k]));
        }

        return $this->_ich[$k];
    }
1016217
public function getChildren()
    {
        $addressbooks = $this->carddavBackend->getAddressBooksForUser($this->principalUri);
        $objs = [];
        foreach ($addressbooks as $addressbook) {
            $objs[] = new AddressBook($this->carddavBackend, $addressbook);
        }

        return $objs;
    }
317569
public function actionIndex()
    {
        $dynamicModel = $this->createAuditForm();
        $auditForm = new AuditForm;
        $auditForm->addFormValidators($dynamicModel);
        $dataProvider = null;
        $arrayDiff = [];
        /** @var Module $module */
        $module = $this->module;
        if ($dynamicModel->load(Yii::$app->request->get()) && $dynamicModel->validate()) {
            $this->setCurrentModel($dynamicModel->table);
            $this->hiddenColumns = array_merge(
                $module->auditColumns,
                $module->tables[$dynamicModel->table]['hiddenColumns']
            );
            $dataProvider = $this->createDataProvider($dynamicModel);
            $arrayDiff = [];
            $previousModel = null;
            foreach ($dataProvider->getModels() as $model) {
                $auditId = $model['audit_id'];
                $model = $this->unsetHiddenColumns($model);
                $arrayDiff[$auditId] = $this->createDiff($model, $dynamicModel, $previousModel, $auditId);
                $previousModel = $model;
            }
        }
        return $this->render('index', [
            'model' => $dynamicModel,
            'dataProvider' => $dataProvider,
            'arrayDiff' => $arrayDiff,
            'fields' => $auditForm->getFormFields($dynamicModel),
            'hiddenColumns' => $this->hiddenColumns,
        ]);
    }
166554
public function sortableAction()
    {
        $admin = $this->getAdmin();

        $admin->checkAccess('edit');

        $request = $this->getRequest();

        /** @var EntityManager $em */
        $em = $this->getDoctrine()->getManager();

        $repository = $em->getRepository($admin->getClass());

        $object = $repository->find($request->request->get('id'));

        // Получаем позицию элемента, после которого должен стоять текущий

        $after_object = $repository->find($request->request->get('after_id'));

        $after_pos = 0;

        if ($after_object) {
            $after_pos = $after_object->getPosition();
        }

        $new_pos = 0;

        // Если позиция не определена, то 1, иначе + 1 от позиции после которого должен стоять.
        if ($after_object) {
            $new_pos = $after_pos + 1;
        }

        // Обновляем позиции текущего
        $object->setPosition($new_pos);

        $admin->update($object);

        return $this->renderJson(
            [
                'result' => 'ok',
                'objectId' => $admin->getNormalizedIdentifier($object),
            ]
        );
    }