Find an instance identified by nb_site_target_section_key field.
@param mixed $nb_medioteca Medioteca that owns Site Target Section
@param string $key Key to search
@return CNabuSiteTargetSection Returns a valid instance if exists or null if not.
559102
public static function findByKey($nb_medioteca, $key)
    {
        $nb_medioteca_id = nb_getMixedValue($nb_medioteca, 'nb_medioteca_id');
        if (is_numeric($nb_medioteca_id)) {
            $retval = CNabuSiteTargetSection::buildObjectFromSQL(
                    'select * '
                    . 'from nb_site_target_section '
                   . 'where nb_medioteca_id=%medioteca_id$d '
                     . "and nb_site_target_section_key='%key\$s'",
                    array(
                        'medioteca_id' => $nb_medioteca_id,
                        'key' => $key
                    )
            );
        } else {
            $retval = null;
        }
        
        return $retval;
    }
745434
public function deactivate($key, $section = null)
    {
        if (is_null($section)) {
            $pieces = explode('.', $key);
            $section = $pieces[0];
            $key = $pieces[1];
        }
        return $this->model->deactivateSetting($section, $key);
    }
1044901
public function setTargetUseURI(string $target_use_uri = "N") : CNabuDataObject
    {
        if ($target_use_uri === null) {
            throw new ENabuCoreException(
                    ENabuCoreException::ERROR_NULL_VALUE_NOT_ALLOWED_IN,
                    array("\$target_use_uri")
            );
        }
        $this->setValue('nb_site_target_cta_target_use_uri', $target_use_uri);
        
        return $this;
    }
1101634
public function find($storageName, $key)
    {
        $qb = $this->conn->createQueryBuilder();

        $qb->select('s.' . $this->dataColumn)
            ->from($this->table, 's')
            ->where($this->keyColumn . ' = ?')
            ->setParameters([$key]);

        $stmt = $qb->execute();

        $data = $stmt->fetchColumn();

        if (! $data) {
            throw new NotFoundException();
        }

        return unserialize($data);
    }
1136327
public function getRoleByKey(string $key)
    {
        if (strlen($key) === 0) {
            throw new ENabuCoreException(
                ENabuCoreException::ERROR_UNEXPECTED_PARAM_VALUE,
                array('$key', print_r($key, true))
            );
        }

        return $this->nb_role_list->getItem($key, CNabuRoleList::INDEX_KEY);
    }
228338
public function setMediotecaId(int $nb_medioteca_id) : CNabuDataObject
    {
        if ($nb_medioteca_id === null) {
            throw new ENabuCoreException(
                    ENabuCoreException::ERROR_NULL_VALUE_NOT_ALLOWED_IN,
                    array("\$nb_medioteca_id")
            );
        }
        $this->setValue('nb_medioteca_id', $nb_medioteca_id);
        
        return $this;
    }
478412
public function hasProperty( $section, $key )
	{
		if( !$this->hasSection( $section ) )
			throw new InvalidArgumentException( 'Section "'.$section.'" is not existing.' ); 
		return array_key_exists( $key, $this->data[$section] );
	}
434499
public function deactivateProperty( $key, $section = NULL)
	{
		if( $this->usesSections() )
		{
			if( !$this->hasProperty( $key, $section ) )
				throw new InvalidArgumentException( 'Key "'.$key.'" is not existing in section "'.$section.'"' );
			if( !$this->isActiveProperty( $key, $section ) )
				throw new LogicException( 'Key "'.$key.'" is already inactive' );
			$this->disabled[$section][] = $key;
			return is_int( $this->write() );
		}
		else
		{
			if( !$this->hasProperty( $key ) )
				throw new InvalidArgumentException( 'Key "'.$key.'" is not existing' );
			if( !$this->isActiveProperty( $key ) )
				throw new LogicException( 'Key "'.$key.'" is already inactive' );
			$this->disabled[] = $key;
			return is_int( $this->write() );
		}
	}
923580
public function findSection($section)
    {
        if (!isset($this->sectionMap[$section])) {
            throw new UnknownSection($section);
        }

        return $this->sectionMap[$section];
    }
1199130
public function setPoliciesTargetUseURI($policies_target_use_uri) : CNabuDataObject
    {
        if ($policies_target_use_uri === null) {
            throw new ENabuCoreException(
                    ENabuCoreException::ERROR_NULL_VALUE_NOT_ALLOWED_IN,
                    array("\$policies_target_use_uri")
            );
        }
        $this->setValue('nb_site_role_policies_target_use_uri', $policies_target_use_uri);
        
        return $this;
    }
1180880
public function getSiteByKey(string $key)
    {
        $retval = false;

        if (strlen($key) === 0) {
            throw new ENabuCoreException(
                ENabuCoreException::ERROR_UNEXPECTED_PARAM_VALUE,
                array('$key', print_r($key, true))
            );
        }

        $nb_site = $this->nb_site_list->getItem($key, CNabuSiteList::INDEX_KEY);

        if ($nb_site instanceof CNabuSite) {
            $nb_site->setCustomer($this);
            $retval = $nb_site;
        }

        return $retval;
    }
1330656
public function acquireItem($key, $index = false)
    {
        if ($index === self::INDEX_KEY) {
            $nb_site = CNabuEngine::getEngine()->getApplication()->getRequest()->getSite();
            $retval = CNabuSiteTarget::findByKey($nb_site, $key);
        } else {
            $retval = parent::acquireItem($key, $index);
        }

        return $retval;
    }
893508
public function addRole(CNabuSiteTargetCTARole $nb_role)
    {
        if ($nb_role->isValueNumeric(NABU_ROLE_FIELD_ID) || $nb_role->isValueGUID(NABU_ROLE_FIELD_ID)) {
            $nb_role->setSiteTargetCTA($this);
            $this->nb_site_target_cta_role_list->addItem($nb_role);
        }

        return $nb_role;
    }
1310400
public function getOneToOne($target, $key = null, $target_key = null){
        $factory = $this->_db->factory($target);
        if(null === $key){
            $key = $this->getPK();
        }
        if(null === $target_key){
            $target_key = $factory->getPK();
        }
        
        return $factory->findOneBy($target_key, $this->get($key));
    }
700560
public static function getInstance($key = null)
    {
        $config = Container::get('config')->get('db');
        if (!is_array($config) || count($config) == 0) {
            return null;
        } elseif ($key == null) {
            $dbKeys = array_keys($config);
            if (isset($dbKeys[0])) {
                $key = $dbKeys[0];
            } else {
                return null;
            }
        }

        Container::get('config')->set('selected_db_key', $key);

        if (!isset(self::$instance[$key])) {
            try {
                self::$instance[$key] = new self($config[$key]);
            } catch (PDOException $e) {
                throw new DatabaseException($e);
            } catch (Exception $e) {
                throw new DatabaseException($e);
            }
        }

        return self::$instance[$key];
    }
1345072
public function setMediotecaItemId(int $nb_medioteca_item_id) : CNabuDataObject
    {
        if ($nb_medioteca_item_id === null) {
            throw new ENabuCoreException(
                    ENabuCoreException::ERROR_NULL_VALUE_NOT_ALLOWED_IN,
                    array("\$nb_medioteca_item_id")
            );
        }
        $this->setValue('nb_medioteca_item_id', $nb_medioteca_item_id);
        
        return $this;
    }
27770
static public function getCTARolesForSiteTarget($nb_site_target)
    {
        $nb_site_target_id = nb_getMixedValue($nb_site_target, NABU_SITE_TARGET_FIELD_ID);
        if (is_numeric($nb_site_target_id)) {
            $retval = CNabuEngine::getEngine()
                    ->getMainDB()
                    ->getQueryAsObjectArray(
                        '\nabu\data\site\CNabuSiteTargetCTARole', null,
                        'select stcr.* '
                        . 'from nb_site_target_cta stc, nb_site_target_cta_role stcr '
                       . 'where stc.nb_site_target_cta_id=stcr.nb_site_target_cta_id '
                         . 'and stc.nb_site_target_id=%target_id$d',
                        array(
                            'target_id' => $nb_site_target_id
                        )
                    )
            ;
        } else {
            $retval = null;
        }

        return $retval;
    }