getApplicationIncrementalFieldsString

Retorna a relação de propriedades vinculadas a persistencia com incremento a partir da aplicação

@return array|boolean
188197
public function getApplicationIncrementalFieldsString()
    {
        if (!empty($this->applicationIncrementalFieldsString)) {
            return $this->applicationIncrementalFieldsString;
        }

        $applicationIncrementalFieldsMeta = $this->getApplicationIncrementalFieldsMeta();
        if (empty($applicationIncrementalFieldsMeta)) {
            return false;
        }

        $this->applicationIncrementalFieldsString = array_map(function (PropertyContract $property) {
            return $property->getField();
        }, $applicationIncrementalFieldsMeta);

        return $this->applicationIncrementalFieldsString;
    }
167184
public function getIncrementalFieldsMeta()
    {
        if (!empty($this->incrementalFieldsMeta)) {
            return $this->incrementalFieldsMeta;
        }

        $incrementalFieldsMeta = $this->getPropertyContainer()->getFields('hasMany');
        if (!empty($incrementalFieldsMeta)) {
            $incrementalFieldsMeta = array_filter(
                $incrementalFieldsMeta,
                function (PropertyContract $property) {
                    if (!$property->getBehavior()->isPersistent()) {
                        return false;
                    }

                    if (!$property->getBehavior() instanceof IntegerBehavior) {
                        return false;
                    }

                    if (!empty($property->getBehavior()->isAutoIncrement())) {
                        return true;
                    }

                    return false;
                }
            );
        }
        $this->incrementalFieldsMeta = $incrementalFieldsMeta;

        return $this->incrementalFieldsMeta;
    }
818923
protected function getFields(): array {
    if (!$this->fields) {
      // Search the pattern for named subpatterns and get their names.
      // @link https://stackoverflow.com/a/47753964/3260408
      preg_match_all("~(?<!\\\\)(?:\\\\{2})*\(\?(?|P?<([_A-Za-z]\w{0,31})>|'([_A-Za-z]\w{0,31})')~", $this->getPattern(), $matches);
      $this->fields = $matches[1];

      if (!$this->fields) {
        throw new \RuntimeException('Pattern must contain named subpatterns.');
      }
      if (count(array_unique($this->fields)) != count($this->fields)) {
        throw new \RuntimeException('Subpattern names must be unique.');
      }
    }

    return $this->fields;
  }
390179
public function getChangedFields()
    {
        if ($this->_snapshot === false) {
            throw new PreconditionException(['getChangedFields failed: `:model` instance is snapshot disabled', 'model' => static::class]);
        }

        $changed = [];

        foreach ($this->getFields() as $field) {
            if (isset($this->_snapshot[$field])) {
                if ($this->{$field} !== $this->_snapshot[$field]) {
                    $changed[] = $field;
                }
            } elseif ($this->$field !== null) {
                $changed[] = $field;
            }
        }

        return $changed;
    }
1184115
public function getApplication()
    {
        if (!($this->_io instanceof IOInterface)) {
            throw new \RuntimeException('Bootstrapper instance requires IOInterface instance. Please call setIO() first.');
        }

        if (!$this->_bootstrapped) {
            $this->_bootstrap();
        }

        if (!($this->_application instanceof Application))
        {
            $options = array(
                'root_user' => $this->_credentials['username'],
                'loglevel'  => $this->_verbosity,
                'platform'  => Util::isJoomlatoolsPlatform()
            );

            try
            {
                $this->_application = new Application($options);
                $this->_application->authenticate($this->_credentials);
            }
            catch (\Exception $ex)
            {
                $this->_io->write("<error>Failed to initialize the Joomla application</error>");

                if ($this->_io->isVerbose()) {
                    $this->_io->write($ex->getMessage());
                }

                if ($this->_io->isDebug()) {
                    throw $ex;
                }

                $this->_application = false;
            }
        }

        return $this->_application;
    }
1003148
public function getForm()
	{
		$form = new App_Form_New();

		$elements = [];

		foreach($this->_settings as $column => $setting)
		{
			if(!$this->recordColumnExists($column) )
			{
				continue;
			}

			if(isset($setting['show_in']) && (isset($setting['show_in']) && !in_array('form', $setting['show_in'])))
			{
				continue;
			}

			$settingColumn = array(
				'type' => 'text'
			);

			if(isset($setting['formOptions']))
			{
				$settingColumn['options'] = $setting['formOptions'];
			}
			elseif(!array_key_exists('options', $settingColumn))
			{
				$settingColumn['options'] = array();
			}

			$type = 'text';
			if(isset($setting['type']))
			{
				$type = $setting['type'];
			}
			if(isset($setting['label']))
			{
				$settingColumn['options']['label'] = $setting['label'];
			}
			elseif(isset($setting['title']))
			{
				$settingColumn['options']['label'] = $setting['title'];
			}

			if(isset($setting['options']['validators']))
			{
				$settingColumn['options']['validators'] = $setting['validators'];
			}
			if(isset($setting['filters']))
			{
				$settingColumn['options']['filters'] = $setting['filters'];
			}
			if(isset($setting['decorators']))
			{
				$settingColumn['options']['decorators'] = $setting['decorators'];
			}

			if(isset($setting['helper']) && isset($setting['helper']['name']))
			{
				/* TODO 20150401 : make helper definition compatible with FormElement one
				$settingColumn['options']['helper'] = $setting['helper']['name'];
				*/
			}

			switch($type)
			{
				case "boolean":
				case "bool":
					if(!isset($settingColumn['options']['decorators']))
					{
						$settingColumn['options']['decorators'] = $form->elementDecorators;
					}
					break;
				case "array":
					if(!isset($settingColumn['options']['decorators']))
					{
						$settingColumn['options']['decorators'] = $form->elementDecorators;
					}
					break;
				case "date":
					if(!isset($settingColumn['options']['validators']['date']))
					{
						$settingColumn['options']['validators']['date'] = array('Date',false,array('Y-m-d'));
					}
					if(!isset($settingColumn['options']['decorators']))
					{
						$settingColumn['options']['decorators'] = $form->elementDecorators;
					}
					break;
				case "datetime":
					if(!isset($settingColumn['options']['validators']['date']))
					{
						$settingColumn['options']['validators']['date'] = array('Date',false,array('Y-m-d H:i:s'));
					}
					if(!isset($settingColumn['options']['decorators']))
					{
						$settingColumn['options']['decorators'] = $form->elementDecorators;
					}
					break;
				case "time":
					if(!isset($settingColumn['options']['validators']['date']))
					{
						$settingColumn['options']['validators']['date'] = array('Date',false,array('H:i:s'));
					}
					if(!isset($settingColumn['options']['decorators']))
					{
						$settingColumn['options']['decorators'] = $form->elementDecorators;
					}
					break;
				case "uint":
				case "int":
					@$settingColumn['options']['validators'][] = 'Int';
					if(!isset($settingColumn['options']['decorators']))
					{
						$settingColumn['options']['decorators'] = $form->elementDecorators;
					}
					break;
				case "float":
					if(!isset($settingColumn['options']['decorators']))
					{
						$settingColumn['options']['decorators'] = $form->elementDecorators;
					}
					break;
				case "email":
					@$settingColumn['options']['validators'][] = 'EmailAddress';
					if(!isset($settingColumn['options']['decorators']))
					{
						$settingColumn['options']['decorators'] = $form->elementDecorators;
					}
					break;
				case "host":
					@$settingColumn['options']['validators'][] = 'Hostname';
					if(!isset($settingColumn['options']['decorators']))
					{
						$settingColumn['options']['decorators'] = $form->elementDecorators;
					}
					break;
				case "text":
					if(!isset($settingColumn['options']['decorators']))
					{
						$settingColumn['options']['decorators'] = $form->elementDecorators;
					}
					break;
				case "hidden":
					if(!isset($settingColumn['options']['decorators']))
					{
						$settingColumn['options']['decorators'] = $form->hiddenDecorators;
					}
					break;
				default:
					debug_assert(false !== array_search($type, self::$types), "Unknown Form Type `{$type}`");
					break;
			}

			if(isset($setting['formType']))
			{
				$settingColumn['type'] = $setting['formType'];
			}
			else
			{
				$settingColumn['type'] = $this->_getFormType($type);
			}
			if(isset($setting['unique']) && $setting['unique'] == true)
			{
				if(!isset($settingColumn['options']['validators']))
				{
					$settingColumn['options']['validators'] = array();
				}
				if(!isset($settingColumn['options']['validators']['unique']))
				{
					$settingColumn['options']['validators']['unique'] = array('Db_RecordNotExistOrIsUnique', false, array(array(
						'table' => $this->getTable(),
						'field' => $column,
						'primary_key' => $this->getPrimaryKey()
					)));
				}
			}
			if(isset($setting['required']) && $setting['required'] == true)
			{
				$settingColumn['options']['required'] = true;
			}

			if(isset($setting['multiOptions']))
			{
				$multiOptions = $setting['multiOptions'];
				if($settingColumn['type'] == 'select' || (isset($settingColumn['formType']) && $settingColumn['formType'] == 'select'))
				{
					$multiOptions = array('' => 'LABEL_SELECT') + $multiOptions;
				}
				$settingColumn['options']['multiOptions'] = $multiOptions;

				if(isset($setting['otherMultioption']) && $setting['formType'] == 'multiCheckbox')
				{
					$settingColumn['options']['otherMultioption'] = $setting['otherMultioption'];
				}
			}

			if(isset($setting['hidden']) && $setting['hidden'] == true)
			{
				$settingColumn['options']['decorators'] = $form->hiddenDecorators;
				$settingColumn['type'] = 'hidden';
			}

			$elements[$column] = $settingColumn;
		}

		$form->setOptions([
			'elements' => $elements
		]);
		$form->setDisableLoadDefaultDecorators(true);

		return $form;
	}
314408
protected function getAppNamespace()
    {
        $composer = json_decode(file_get_contents(base_path().'/composer.json'), true);

        foreach ((array) data_get($composer, 'autoload.psr-4') as $namespace => $path) {
            foreach ((array) $path as $pathChoice) {
                if (realpath(app_path()) == realpath(base_path().'/'.$pathChoice)) {
                    return $namespace;
                }
            }
        }

        throw new \RuntimeException('Unable to detect application namespace.');
    }
621854
public function getApplication(): ?Application
    {
        if ($this instanceof Application) {
            return $this;
        }

        if ($p = $this->parent) {
            return $p->getApplication();
        }

        return null;
    }
321837
protected function getFieldsExistingMessages()
    {
        $fieldsMessages = [];
        $formObject = $this->getFormObject();

        if ($formObject->formWasSubmitted()
            && $formObject->hasFormResult()
        ) {
            foreach ($this->getFormObject()->getConfiguration()->getFields() as $field) {
                $fieldsMessages[$field->getName()] = $this->getSingleFieldExistingMessages($field);
            }
        }

        return $fieldsMessages;
    }
117257
public function getFields()
    {
        $fields = array_keys($this->fillable);
        if (!empty($fields) && is_integer($fields[0]))
            // only alias provided
            $fields = array_values($this->fillable);

        return array_merge($fields, $this->appends, array_keys($this->attributes));
    }
1109010
public function toOptionArray()
    {
        $fields = [];
        $fields[] = ['value' => '0', 'label' => '-- Disabled --'];
        $website = $this->helper->getWebsiteForSelectedScopeInAdmin();

        if ($this->helper->isEnabled($website)) {
            $savedPrograms = $this->registry->registry('programs');

            //get saved datafileds from registry
            if (is_array($savedPrograms)) {
                $programs = $savedPrograms;
            } else {
                //grab the datafields request and save to register
                $client = $this->helper->getWebsiteApiClient($website);
                $programs = $client->getPrograms();
                $this->registry->unregister('programs');
                $this->registry->register('programs', $programs);
            }

            //set the api error message for the first option
            if (isset($programs->message)) {
                //message
                $fields[] = ['value' => 0, 'label' => $programs->message];
            } elseif (!empty($programs)) {
                //loop for all programs option
                foreach ($programs as $program) {
                    if (isset($program->id) && $program->status == 'Active') {
                        $fields[] = [
                            'value' => $program->id,
                            'label' => $program->name,
                        ];
                    }
                }
            }
        }

        return $fields;
    }
371889
protected function getClassNameRemappingFields()
    {
        $dataClasses = ClassInfo::getValidSubClasses(DataObject::class);
        $schema = DataObject::getSchema();
        $remapping = [];

        foreach ($dataClasses as $className) {
            $fieldSpecs = $schema->fieldSpecs($className);
            foreach ($fieldSpecs as $fieldName => $fieldSpec) {
                if (Injector::inst()->create($fieldSpec, 'Dummy') instanceof DBClassName) {
                    $remapping[$className][] = $fieldName;
                }
            }
        }

        return $remapping;
    }
164127
public function getApplicationUseNow(){
		$tmp=explode('/', preg_replace('/^[\/]*(.*?)[\/]*$/', '\\1', $_SERVER['REQUEST_URI']));


		foreach ($tmp as $key => $value) {
			if(isset($tmp[$key]) && is_array($this->getApplication()) && array_key_exists($tmp[$key],$this->getApplication())){
				for ($i=0; $i < $key; $i++) {
					array_shift($tmp);
				}
				$app_path = $this->getApplication();
				$app_public = $app_path[$tmp[0]]['path_public'];
				$app_path = $app_path[$tmp[0]]['path_app'];
				$this->setNameApplication($tmp[0]);
			}
		}

		for ($i=0; $i < count($key); $i++) {
			array_shift($tmp);
		}

		if(!isset($app_path)){
			$app_path = $this->getApplication();
			$app_public=$app_path['default']['path_public'];
			$app_path=$app_path['default']['path_app'];
			$this->setNameApplication('default');
		}

		$this->setApplicationName($app_path);
		if(!file_exists(PATH_ROOT.$app_public)){
			throw new \Exception("app_public não foi encontrado em: ".PATH_ROOT.$app_public);
		}else{
			$this->setPublicPath($app_public);
		}

	}
509674
public function getCMSFields()
    {
        $fields = $this->scaffoldFormFields(
            array(
                // Don't allow has_many/many_many relationship editing before the record is first saved
                'includeRelations' => ($this->ID > 0),
                'tabbed' => true,
                'ajaxSafe' => true
            )
        );
        $fields->removeByName(
            array(
                'Title',
                'Instance',
                'Style',
                'Objects'
            )
        );
        if (!$this->IsMain) {
            $fields->addFieldsToTab(
                'Root.Main',
                array(
                    TextField::create(
                        'Title',
                        _t('PlaceableObject_Preset.TITLE', 'Title')
                    ),
                    DropdownField::create(
                        'Instance',
                        _t('PlaceableObject_Preset.INSTANCE', 'Instance'),
                        singleton('PlaceableObject_Preset')->dbObject('Instance')->enumValues()
                    )
                )
            );
        }
        if ($this->Styles) {
            $fields->addFieldToTab(
                'Root.Main',
                DropdownField::create(
                    'Style',
                    _t('PlaceableObject_Preset.STYLE', 'Style'),
                    $this->Styles
                )->setEmptyString(_t('PlaceableObject_Preset.DEFAULTSTYLE', 'Default'))
            );
        }
        $fields->addFieldsToTab(
            'Root.Objects',
            array(
                LabelField::create(
                    'ObjectsDescription',
                    _t('PlaceableObject_Preset.OBJECTSDESCRIPTION', 'List of all objects that use this use this preset.')
                ),
                GridField::create(
                    'Objects',
                    _t('PlaceableObject_Preset.OBJECTS', 'Objects'),
                    $this->Objects(),
                    GridFieldConfig_Base::create()
                )
            )
        );
        $this->extend('updateCMSFields', $fields);
        return $fields;
    }
1130548
public function getSurveyApplicationValues()
    {
        static $data;

        if (! $data) {
            $data = array(
                self::APPLY_NOT  => $this->_('No'),
                self::APPLY_DO   => $this->_('Yes (for individual tokens)'),
                self::APPLY_STOP => $this->_('Stop (for tokens in uncompleted tracks)'));
        }

        return $data;
    }
1204590
public function getImportCurrentDataApplication(){

		$app_config = $this->getAppConfigYaml();

		foreach ($app_config[$this->getApplicationName()] as $key => $value) {
            if(isset($value['address_uri'])){
				$addresUri = explode('/', $value['address_uri']);
                if(!empty($addresUri[0]) && strpos($_SERVER['HTTP_HOST'] , $addresUri[0]) !== false ){
                	$this->setEnvironmentStatus($key);

                    if($this->getEnvironmentStatus()=='production' || $this->getEnvironmentStatus()=='staging'){
                    	$dir_path = 'prod';
                    }else if($this->getEnvironmentStatus()=='testing' || $this->getEnvironmentStatus()=='development'){
                    	$dir_path = 'dev';
                    	if(file_exists(PATH_ROOT.'/app/dev/') && file_exists(PATH_ROOT.'/app/prod/')){
                    		unlink(file_exists(PATH_ROOT.'/app/dev/'));
                    	}
                    }

                	if(!file_exists(PATH_ROOT.'/app/'.$dir_path)){
                		if($this->getEnvironmentStatus()!='development' && $this->getEnvironmentStatus()!='testing' && file_exists(PATH_ROOT.'/app/dev/')){
                			rename(PATH_ROOT.'/app/dev/', PATH_ROOT.'/app/'.$dir_path );
                		}else if($this->getEnvironmentStatus()!='production' && $this->getEnvironmentStatus()!='staging' && file_exists(PATH_ROOT.'/app/prod/')){
                			rename(PATH_ROOT.'/app/prod/', PATH_ROOT.'/app/'.$dir_path );
                		}
                	}
                    $this->setApplicationPath('/app/'.$dir_path.'/'.$this->getApplicationName());
                    break;
                }
            }

		}


		//Get address_uri of file app_config.yml
		if($this->getEnvironmentStatus()=='production'){
			if(isset($app_config[$this->getNameApplication()]['production'])){
				$c=$app_config[$this->getNameApplication()]['production'];
				$this->setAddressUri($c['address_uri']);
				$this->setUseHttps($c['use_https']);
				$this->setUseWww($c['use_www']);
			}
		}else if($this->getEnvironmentStatus()=='staging'){
			if(isset($app_config[$this->getNameApplication()]['staging'])){
				$c=$app_config[$this->getNameApplication()]['staging'];
				$this->setAddressUri($c['address_uri']);
				$this->setUseHttps($c['use_https']);
				$this->setUseWww($c['use_www']);
			}
		}else if($this->getEnvironmentStatus()=='testing'){
			if(isset($app_config[$this->getNameApplication()]['testing'])){
				$c=$app_config[$this->getNameApplication()]['testing'];
				$this->setAddressUri($c['address_uri']);
				$this->setUseHttps($c['use_https']);
				$this->setUseWww($c['use_www']);
			}
		}else if($this->getEnvironmentStatus()=='development'){
			if(isset($app_config[$this->getNameApplication()]['development'])){
				$c=$app_config[$this->getNameApplication()]['development'];
				$this->setAddressUri($c['address_uri']);
				$this->setUseHttps($c['use_https']);
				$this->setUseWww($c['use_www']);
			}
		}


		//Get address_uri of file app_config.yml
		if($this->getEnvironmentStatus()=='production'){
			if(isset($app_config['address_uri_production'])){
				$this->setAddressUri($app_config['address_uri_production']);
			}
		}else if($this->getEnvironmentStatus()=='staging'){
			if(isset($app_config['address_uri_staging'])){
				$this->setAddressUri($app_config['address_uri_staging']);
			}
		}else if($this->getEnvironmentStatus()=='testing'){
			if(isset($app_config['address_uri_testing'])){
				$this->setAddressUri($app_config['address_uri_testing']);
			}
		}else if($this->getEnvironmentStatus()=='development'){
			if(isset($app_config['address_uri_development'])){
				$this->setAddressUri($app_config['address_uri_development']);
			}
		}

		if($this->getAddressUri()==''){
			throw new \Exception("Você deve definir uma url em address_uri_".$this->getEnvironmentStatus().' no arquivo de configuração do app_config.yml');
		}

		$this->setConnectionDb($app_config);

	}
1236131
private function getApplyValue()
    {
        $value = $this->getValue();

        if (is_array($this->getApplyFilterValue())) {
            $value = $this->getApplyFilterValue();
        }

        if (is_array($value) && count($value) == 1) {
            $value = current($value);
        }

        return $value;
    }