idx
int64
0
60.3k
question
stringlengths
101
6.21k
target
stringlengths
7
803
18,000
public function setParent ( $ parent ) { $ this -> parent = $ parent ; if ( $ this -> parentCallback ) { call_user_func ( $ this -> parentCallback ) ; } return $ this ; }
Set the parent
18,001
public function setCallback ( Callable $ callback , bool $ force = false ) { if ( $ force || ! $ this -> parentCallback ) { $ this -> parentCallback = $ callback ; } return $ this ; }
Set a callback
18,002
public function withFoundation ( ) { $ this -> make ( 'events' ) -> listen ( 'orchestra.auth: roles' , UserAccess :: class ) ; $ this -> registerMemoryBindings ( ) ; $ this -> registerAuthorizationBindings ( ) ; return $ this ; }
Bootstrap Orchestra Platform Foundation .
18,003
protected function getPrimaryConstraint ( $ force = false ) { if ( $ this -> primary_constraint === null || $ force ) { $ this -> primary_constraint = null ; if ( array_key_exists ( 'constraints' , $ this -> storage_descriptor ) ) { foreach ( $ this -> storage_descriptor [ 'constraints' ] as $ constraint ) { if ( is_array ( $ constraint ) && array_key_exists ( 'primary' , $ constraint ) && $ constraint [ 'primary' ] === true ) { $ this -> primary_constraint = $ constraint ; break ; } } } } return $ this -> primary_constraint ; }
Gets the Primary Constraint array fragment of the descriptor . This method is protected to prevent to expose the array to public accesses .
18,004
public function setSiteTargetCTA ( CNabuSiteTargetCTA $ nb_site_target_cta , $ field = NABU_SITE_TARGET_CTA_FIELD_ID ) { $ this -> nb_site_target_cta = $ nb_site_target_cta ; if ( $ this instanceof CNabuDataObject ) { $ this -> transferValue ( $ nb_site_target_cta , NABU_SITE_TARGET_CTA_FIELD_ID , $ field ) ; } return $ this ; }
Sets the Site Target CTA instance that owns this object and sets the field containing the site id .
18,005
public function getMedioteca ( $ nb_customer = false , $ force = false ) { if ( ( $ this -> nb_medioteca === null || $ force ) && ! $ this -> isValueNull ( NABU_MEDIOTECA_FIELD_ID ) ) { $ this -> nb_medioteca = null ; if ( ( $ nb_final_cust = nb_grantCustomer ( $ nb_customer , $ force ) ) !== false ) { $ this -> nb_medioteca = $ nb_final_cust -> getMedioteca ( $ this ) ; } } return $ this -> nb_medioteca ; }
Gets the Medioteca instance using the field value contained in parent class CNabuDataObject
18,006
public function setMedioteca ( CNabuMedioteca $ nb_medioteca , $ field = NABU_MEDIOTECA_FIELD_ID ) { $ this -> nb_medioteca = $ nb_medioteca ; if ( $ this instanceof CNabuDataObject ) { $ this -> transferValue ( $ nb_medioteca , NABU_MEDIOTECA_FIELD_ID , $ field ) ; } return $ this ; }
Sets the Medioteca instance that owns this object and sets the field containing the Medioteca id .
18,007
public static function getAllMediotecas ( CNabuCustomer $ nb_customer ) { $ nb_customer_id = nb_getMixedValue ( $ nb_customer , 'nb_customer_id' ) ; if ( is_numeric ( $ nb_customer_id ) ) { $ retval = forward_static_call ( array ( get_called_class ( ) , 'buildObjectListFromSQL' ) , 'nb_medioteca_id' , 'select * ' . 'from nb_medioteca ' . 'where nb_customer_id=%cust_id$d' , array ( 'cust_id' => $ nb_customer_id ) , $ nb_customer ) ; } else { $ retval = new CNabuMediotecaList ( ) ; } return $ retval ; }
Get all items in the storage as an associative array where the field nb_medioteca_id is the index and each value is an instance of class CNabuMediotecaBase .
18,008
public static function getCustomerUsedLanguages ( $ nb_customer ) { $ nb_customer_id = nb_getMixedValue ( $ nb_customer , NABU_CUSTOMER_FIELD_ID ) ; if ( is_numeric ( $ nb_customer_id ) ) { $ nb_language_list = CNabuLanguage :: buildObjectListFromSQL ( 'nb_language_id' , 'select l.* ' . 'from nb_language l, ' . '(select distinct nb_language_id ' . 'from nb_medioteca ca, nb_medioteca_lang cal ' . 'where ca.nb_medioteca_id=cal.nb_medioteca_id ' . 'and ca.nb_customer_id=%cust_id$d) as lid ' . 'where l.nb_language_id=lid.nb_language_id' , array ( 'cust_id' => $ nb_customer_id ) ) ; } else { $ nb_language_list = new CNabuLanguageList ( ) ; } return $ nb_language_list ; }
Get all language instances used along of all Medioteca set of a Customer
18,009
public static function forge ( $ classname = null , $ db_table_alias = null , $ escape = true ) { if ( ! is_null ( $ classname ) ) { $ object = new $ classname ; } else if ( get_called_class ( ) != "Pragma\ORM\QueryBuilder" ) { $ object = new static ( ) ; } else { throw new \ Exception ( "QueryBuilder can't be built without classname" ) ; } $ object -> db_table_alias = $ db_table_alias ; $ object -> escape = $ escape ; return $ object ; }
in order to get an instance on which execute the query
18,010
public static function encode ( $ cacheVersion = WurflConstants :: API_NAMESPACE , $ namespace = AbstractAdapter :: DEFAULT_NAMESPACE , $ cacheId = '' ) { $ cacheId = implode ( ':' , array ( $ cacheVersion , $ namespace , $ cacheId ) ) ; return hash ( 'sha512' , $ cacheId ) ; }
Encode the Object Id using the Persistence Identifier
18,011
public function getTemplateConnections ( bool $ force = false ) : CNabuMessagingServiceTemplateList { if ( $ this -> nb_messaging_template_service_list -> isEmpty ( ) || $ force ) { $ this -> nb_messaging_template_service_list -> clear ( ) ; $ this -> nb_messaging_template_service_list -> merge ( CNabuMessagingServiceTemplate :: getTemplatesForService ( $ this ) ) ; } return $ this -> nb_messaging_template_service_list ; }
Gets all Template connections for this Service .
18,012
public function isTemplateConnected ( $ nb_template ) : bool { $ retval = false ; if ( is_numeric ( $ nb_template_id = nb_getMixedValue ( $ nb_template , NABU_MESSAGING_TEMPLATE_FIELD_ID ) ) ) { $ this -> getTemplateConnections ( ) ; $ retval = $ this -> nb_messaging_template_service_list -> containsKey ( $ nb_template_id ) ; } return $ retval ; }
Checks if a Template is connected to this Service .
18,013
public static function getActiveMessagingServices ( CNabuMessaging $ nb_messaging ) { $ nb_messaging_id = nb_getMixedValue ( $ nb_messaging , 'nb_messaging_id' ) ; if ( is_numeric ( $ nb_messaging_id ) ) { $ retval = forward_static_call ( array ( get_called_class ( ) , 'buildObjectListFromSQL' ) , 'nb_messaging_service_id' , 'SELECT * FROM nb_messaging_service WHERE nb_messaging_id=%messaging_id$d AND nb_messaging_service_status=\'E\'' , array ( 'messaging_id' => $ nb_messaging_id ) , $ nb_messaging ) ; } else { $ retval = new CNabuMessagingServiceList ( ) ; } return $ retval ; }
Get active items in the storage as an associative array where the field nb_messaging_service_id is the index and each value is an instance of class CNabuMessagingServiceBase .
18,014
public function getUser ( $ force = false ) { if ( $ this -> nb_user === null || $ force ) { $ this -> nb_user = null ; if ( $ this instanceof CNabuDataObject && $ this -> contains ( NABU_USER_FIELD_ID ) && $ this -> isValueNumeric ( NABU_USER_FIELD_ID ) ) { $ nb_user = new CNabuUser ( $ this -> getValue ( NABU_USER_FIELD_ID ) ) ; if ( $ nb_user -> isFetched ( ) ) { $ this -> nb_user = $ nb_user ; } } } return $ this -> nb_user ; }
Gets the User instance .
18,015
public function setUser ( CNabuUser $ nb_user ) { $ this -> nb_user = $ nb_user ; if ( $ this instanceof CNabuDataObject ) { $ this -> transferValue ( $ nb_user , NABU_USER_FIELD_ID ) ; } return $ this ; }
Sets the User instance that owns this object and sets the field containing the User id .
18,016
public function setSiteTarget ( CNabuSiteTarget $ nb_site_target = null , $ field = NABU_SITE_TARGET_FIELD_ID ) { $ this -> nb_site_target = $ nb_site_target ; if ( $ this instanceof CNabuDataObject ) { if ( $ nb_site_target instanceof CNabuSiteTarget ) { $ this -> transferValue ( $ nb_site_target , NABU_SITE_TARGET_FIELD_ID , $ field ) ; } else { $ this -> setValue ( $ field , null ) ; } } return $ this ; }
Sets the Site Target instance that owns this object and sets the field containing the site id .
18,017
protected function bindAuthForApiToken ( ) { Auth :: viaRequest ( 'api' , function ( $ request ) { if ( $ request -> input ( 'api_token' ) ) { return User :: where ( 'api_token' , $ request -> input ( 'api_token' ) ) -> first ( ) ; } } ) ; }
Bind authentication for API Token .
18,018
protected function bindAuthForJwtToken ( ) { Auth :: viaRequest ( 'jwt' , function ( $ request ) { try { if ( ! $ user = JWTAuth :: parseToken ( ) -> authenticate ( ) ) { return ; } } catch ( Exception $ e ) { return ; } return $ user ; } ) ; }
Bind authentication for JWT Token .
18,019
public function toArray ( ) { $ out = [ ] ; foreach ( $ this -> setFields as $ key ) { $ property = $ this -> { $ key } ; if ( $ property instanceof DateTime ) { $ out [ $ key ] = $ property -> format ( DateTime :: ISO8601 ) ; } else { $ out [ $ key ] = $ property ; } } return $ out ; }
Get an array of class properties
18,020
public function setSiteMapId ( int $ nb_site_map_id = 0 ) : CNabuDataObject { if ( $ nb_site_map_id === null ) { throw new ENabuCoreException ( ENabuCoreException :: ERROR_NULL_VALUE_NOT_ALLOWED_IN , array ( "\$nb_site_map_id" ) ) ; } $ this -> setValue ( 'nb_site_map_id' , $ nb_site_map_id ) ; return $ this ; }
Sets the Site Map Id attribute value .
18,021
public function setZone ( string $ zone = "B" ) : CNabuDataObject { if ( $ zone === null ) { throw new ENabuCoreException ( ENabuCoreException :: ERROR_NULL_VALUE_NOT_ALLOWED_IN , array ( "\$zone" ) ) ; } $ this -> setValue ( 'nb_site_map_role_zone' , $ zone ) ; return $ this ; }
Sets the Site Map Role Zone attribute value .
18,022
public static function getAllDomainZones ( CNabuCustomer $ nb_customer ) { $ nb_customer_id = nb_getMixedValue ( $ nb_customer , 'nb_customer_id' ) ; if ( is_numeric ( $ nb_customer_id ) ) { $ retval = forward_static_call ( array ( get_called_class ( ) , 'buildObjectListFromSQL' ) , 'nb_domain_zone_id' , 'select * ' . 'from nb_domain_zone ' . 'where nb_customer_id=%cust_id$d' , array ( 'cust_id' => $ nb_customer_id ) , $ nb_customer ) ; } else { $ retval = new CNabuDomainZoneList ( ) ; } return $ retval ; }
Get all items in the storage as an associative array where the field nb_domain_zone_id is the index and each value is an instance of class CNabuDomainZoneBase .
18,023
public function setOrigin ( $ origin ) : CNabuDataObject { if ( $ origin === null ) { throw new ENabuCoreException ( ENabuCoreException :: ERROR_NULL_VALUE_NOT_ALLOWED_IN , array ( "\$origin" ) ) ; } $ this -> setValue ( 'nb_domain_zone_origin' , $ origin ) ; return $ this ; }
Sets the Domain Zone Origin attribute value .
18,024
public function setTtl ( int $ ttl = 86400 ) : CNabuDataObject { if ( $ ttl === null ) { throw new ENabuCoreException ( ENabuCoreException :: ERROR_NULL_VALUE_NOT_ALLOWED_IN , array ( "\$ttl" ) ) ; } $ this -> setValue ( 'nb_domain_zone_ttl' , $ ttl ) ; return $ this ; }
Sets the Domain Zone Ttl attribute value .
18,025
public function setAdminEmail ( string $ admin_email ) : CNabuDataObject { if ( $ admin_email === null ) { throw new ENabuCoreException ( ENabuCoreException :: ERROR_NULL_VALUE_NOT_ALLOWED_IN , array ( "\$admin_email" ) ) ; } $ this -> setValue ( 'nb_domain_zone_admin_email' , $ admin_email ) ; return $ this ; }
Sets the Domain Zone Admin Email attribute value .
18,026
public function setSerial ( int $ serial = 1 ) : CNabuDataObject { if ( $ serial === null ) { throw new ENabuCoreException ( ENabuCoreException :: ERROR_NULL_VALUE_NOT_ALLOWED_IN , array ( "\$serial" ) ) ; } $ this -> setValue ( 'nb_domain_zone_serial' , $ serial ) ; return $ this ; }
Sets the Domain Zone Serial attribute value .
18,027
public function setRefresh ( int $ refresh = 10800 ) : CNabuDataObject { if ( $ refresh === null ) { throw new ENabuCoreException ( ENabuCoreException :: ERROR_NULL_VALUE_NOT_ALLOWED_IN , array ( "\$refresh" ) ) ; } $ this -> setValue ( 'nb_domain_zone_refresh' , $ refresh ) ; return $ this ; }
Sets the Domain Zone Refresh attribute value .
18,028
public function setRetry ( int $ retry = 3600 ) : CNabuDataObject { if ( $ retry === null ) { throw new ENabuCoreException ( ENabuCoreException :: ERROR_NULL_VALUE_NOT_ALLOWED_IN , array ( "\$retry" ) ) ; } $ this -> setValue ( 'nb_domain_zone_retry' , $ retry ) ; return $ this ; }
Sets the Domain Zone Retry attribute value .
18,029
public function setExpiry ( int $ expiry = 604800 ) : CNabuDataObject { if ( $ expiry === null ) { throw new ENabuCoreException ( ENabuCoreException :: ERROR_NULL_VALUE_NOT_ALLOWED_IN , array ( "\$expiry" ) ) ; } $ this -> setValue ( 'nb_domain_zone_expiry' , $ expiry ) ; return $ this ; }
Sets the Domain Zone Expiry attribute value .
18,030
public function setMinimum ( int $ minimum = 10800 ) : CNabuDataObject { if ( $ minimum === null ) { throw new ENabuCoreException ( ENabuCoreException :: ERROR_NULL_VALUE_NOT_ALLOWED_IN , array ( "\$minimum" ) ) ; } $ this -> setValue ( 'nb_domain_zone_minimum' , $ minimum ) ; return $ this ; }
Sets the Domain Zone Minimum attribute value .
18,031
public function setDns01 ( string $ dns_01 ) : CNabuDataObject { if ( $ dns_01 === null ) { throw new ENabuCoreException ( ENabuCoreException :: ERROR_NULL_VALUE_NOT_ALLOWED_IN , array ( "\$dns_01" ) ) ; } $ this -> setValue ( 'nb_domain_zone_dns_01' , $ dns_01 ) ; return $ this ; }
Sets the Domain Zone Dns 01 attribute value .
18,032
public function setDns02 ( string $ dns_02 ) : CNabuDataObject { if ( $ dns_02 === null ) { throw new ENabuCoreException ( ENabuCoreException :: ERROR_NULL_VALUE_NOT_ALLOWED_IN , array ( "\$dns_02" ) ) ; } $ this -> setValue ( 'nb_domain_zone_dns_02' , $ dns_02 ) ; return $ this ; }
Sets the Domain Zone Dns 02 attribute value .
18,033
public function setDnsOrigin ( $ dns_origin ) : CNabuDataObject { if ( $ dns_origin === null ) { throw new ENabuCoreException ( ENabuCoreException :: ERROR_NULL_VALUE_NOT_ALLOWED_IN , array ( "\$dns_origin" ) ) ; } $ this -> setValue ( 'nb_domain_zone_dns_origin' , $ dns_origin ) ; return $ this ; }
Sets the Domain Zone Dns Origin attribute value .
18,034
public function setShareAll ( string $ share_all = "F" ) : CNabuDataObject { if ( $ share_all === null ) { throw new ENabuCoreException ( ENabuCoreException :: ERROR_NULL_VALUE_NOT_ALLOWED_IN , array ( "\$share_all" ) ) ; } $ this -> setValue ( 'nb_domain_zone_share_all' , $ share_all ) ; return $ this ; }
Sets the Domain Zone Share All attribute value .
18,035
public static function hydrateCollection ( array $ settings ) { $ hydrated = [ ] ; foreach ( $ settings as $ setting ) { $ hydrated [ ] = self :: hydrate ( $ setting ) ; } return $ hydrated ; }
Hydrate a collection of settings objects into a SettingEntity collection
18,036
public static function hydrate ( stdClass $ setting ) { $ hydrated = new SettingEntity ( ) ; if ( isset ( $ setting -> key ) ) { $ hydrated -> setKey ( $ setting -> key ) ; } if ( isset ( $ setting -> value ) ) { $ hydrated -> setValue ( $ setting -> value ) ; } if ( isset ( $ setting -> created_at ) ) { $ hydrated -> setCreatedAt ( new DateTime ( $ setting -> created_at ) ) ; } return $ hydrated ; }
Hydrate a setting object into a SettingEntity
18,037
public static function getAllMessagingTemplates ( CNabuMessaging $ nb_messaging ) { $ nb_messaging_id = nb_getMixedValue ( $ nb_messaging , 'nb_messaging_id' ) ; if ( is_numeric ( $ nb_messaging_id ) ) { $ retval = forward_static_call ( array ( get_called_class ( ) , 'buildObjectListFromSQL' ) , 'nb_messaging_template_id' , 'select * ' . 'from nb_messaging_template ' . 'where nb_messaging_id=%messaging_id$d' , array ( 'messaging_id' => $ nb_messaging_id ) , $ nb_messaging ) ; } else { $ retval = new CNabuMessagingTemplateList ( ) ; } return $ retval ; }
Get all items in the storage as an associative array where the field nb_messaging_template_id is the index and each value is an instance of class CNabuMessagingTemplateBase .
18,038
protected function registerEntityScanner ( ) { $ app = $ this -> app ; $ app -> singleton ( 'datamapper.entity.scanner' , function ( $ app ) { $ reader = $ app [ 'datamapper.annotationreader' ] ; $ validator = new EntityValidator ; return new EntityScanner ( $ reader , $ validator ) ; } ) ; }
Register the entity scanner implementation .
18,039
public static function findByKey ( $ nb_catalog , $ key ) { $ nb_catalog_id = nb_getMixedValue ( $ nb_catalog , 'nb_catalog_id' ) ; if ( is_numeric ( $ nb_catalog_id ) ) { $ retval = CNabuCatalogTag :: buildObjectFromSQL ( 'select * ' . 'from nb_catalog_tag ' . 'where nb_catalog_id=%catalog_id$d ' . "and nb_catalog_tag_key='%key\$s'" , array ( 'catalog_id' => $ nb_catalog_id , 'key' => $ key ) ) ; } else { $ retval = null ; } return $ retval ; }
Find an instance identified by nb_catalog_tag_key field .
18,040
public static function getAllCatalogTags ( CNabuCatalog $ nb_catalog ) { $ nb_catalog_id = nb_getMixedValue ( $ nb_catalog , 'nb_catalog_id' ) ; if ( is_numeric ( $ nb_catalog_id ) ) { $ retval = forward_static_call ( array ( get_called_class ( ) , 'buildObjectListFromSQL' ) , 'nb_catalog_tag_id' , 'select * ' . 'from nb_catalog_tag ' . 'where nb_catalog_id=%catalog_id$d' , array ( 'catalog_id' => $ nb_catalog_id ) , $ nb_catalog ) ; } else { $ retval = new CNabuCatalogTagList ( ) ; } return $ retval ; }
Get all items in the storage as an associative array where the field nb_catalog_tag_id is the index and each value is an instance of class CNabuCatalogTagBase .
18,041
public static function getFilteredCatalogTagList ( $ nb_catalog , $ q = null , $ fields = null , $ order = null , $ offset = 0 , $ num_items = 0 ) { $ nb_catalog_id = nb_getMixedValue ( $ nbu_customer , NABU_CATALOG_FIELD_ID ) ; if ( is_numeric ( $ nb_catalog_id ) ) { $ fields_part = nb_prefixFieldList ( CNabuCatalogTagBase :: getStorageName ( ) , $ fields , false , true , '`' ) ; $ order_part = nb_prefixFieldList ( CNabuCatalogTagBase :: getStorageName ( ) , $ fields , false , false , '`' ) ; if ( $ num_items !== 0 ) { $ limit_part = ( $ offset > 0 ? $ offset . ', ' : '' ) . $ num_items ; } else { $ limit_part = false ; } $ nb_item_list = CNabuEngine :: getEngine ( ) -> getMainDB ( ) -> getQueryAsArray ( "select " . ( $ fields_part ? $ fields_part . ' ' : '* ' ) . 'from nb_catalog_tag ' . 'where ' . NABU_CATALOG_FIELD_ID . '=%catalog_id$d ' . ( $ order_part ? "order by $order_part " : '' ) . ( $ limit_part ? "limit $limit_part" : '' ) , array ( 'catalog_id' => $ nb_catalog_id ) ) ; } else { $ nb_item_list = null ; } return $ nb_item_list ; }
Gets a filtered list of Catalog Tag instances represented as an array . Params allows the capability of select a subset of fields order by concrete fields or truncate the list by a number of rows starting in an offset .
18,042
public function getFactory ( CNabuMessaging $ nb_messaging ) { $ retval = false ; $ nb_customer = $ this -> getCustomer ( ) ; if ( $ nb_messaging -> validateCustomer ( $ nb_customer ) ) { if ( is_numeric ( $ nb_messaging_id = nb_getMixedValue ( $ nb_messaging , NABU_MESSAGING_FIELD_ID ) ) ) { $ retval = $ this -> nb_messaging_factory_list -> getItem ( $ nb_messaging_id ) ; } if ( ! $ retval ) { $ retval = $ this -> nb_messaging_factory_list -> addItem ( new CNabuMessagingFactory ( $ nb_messaging ) ) ; } } else { throw new ENabuCoreException ( ENabuCoreException :: ERROR_CUSTOMERS_DOES_NOT_MATCH ) ; } return $ retval ; }
Gets a Messaging Factory instance for a Messaging instance . If Factory instance already exists then returns it .
18,043
public static function hydrateCollection ( array $ libraries ) { $ hydrated = [ ] ; foreach ( $ libraries as $ library ) { $ hydrated [ ] = self :: hydrate ( $ library ) ; } return $ hydrated ; }
Hydrate a collection of library objects into a collection of LibraryEntity objects
18,044
public static function hydrate ( stdClass $ library ) { $ hydrated = new LibraryEntity ( ) ; if ( isset ( $ library -> id ) ) { $ hydrated -> setId ( $ library -> id ) ; } if ( isset ( $ library -> name ) ) { $ hydrated -> setName ( $ library -> name ) ; } if ( isset ( $ library -> version ) ) { $ hydrated -> setVersion ( $ library -> version ) ; } if ( isset ( $ library -> implementation ) ) { $ hydrated -> setImplementation ( $ library -> implementation ) ; } if ( isset ( $ library -> group ) ) { $ hydrated -> setGroup ( $ library -> group ) ; } return $ hydrated ; }
Hydrate a library object into a LibraryEntity object
18,045
public function isLinkDead ( $ url ) { $ deadVal = $ this -> areLinksDead ( [ $ url ] ) ; $ deadVal = $ deadVal [ $ url ] ; return $ deadVal ; }
Check if a single URL is dead by performing a curl request
18,046
protected function performFullRequest ( $ urls ) { $ multicurl_resource = curl_multi_init ( ) ; if ( $ multicurl_resource === false ) { return false ; } $ curl_instances = [ ] ; $ deadlinks = [ ] ; foreach ( $ urls as $ id => $ url ) { $ curl_instances [ $ id ] = curl_init ( ) ; if ( $ curl_instances [ $ id ] === false ) { return false ; } curl_setopt_array ( $ curl_instances [ $ id ] , $ this -> getCurlOptions ( $ this -> sanitizeURL ( $ url , false , true ) , true ) ) ; curl_multi_add_handle ( $ multicurl_resource , $ curl_instances [ $ id ] ) ; } $ active = null ; do { $ mrc = curl_multi_exec ( $ multicurl_resource , $ active ) ; } while ( $ mrc == CURLM_CALL_MULTI_PERFORM ) ; while ( $ active && $ mrc == CURLM_OK ) { if ( curl_multi_select ( $ multicurl_resource ) == - 1 ) { usleep ( 100 ) ; } do { $ mrc = curl_multi_exec ( $ multicurl_resource , $ active ) ; } while ( $ mrc == CURLM_CALL_MULTI_PERFORM ) ; } foreach ( $ urls as $ id => $ url ) { $ headers = curl_getinfo ( $ curl_instances [ $ id ] ) ; $ error = curl_errno ( $ curl_instances [ $ id ] ) ; $ errormsg = curl_error ( $ curl_instances [ $ id ] ) ; $ curlInfo = [ 'http_code' => $ headers [ 'http_code' ] , 'effective_url' => $ headers [ 'url' ] , 'curl_error' => $ error , 'curl_error_msg' => $ errormsg , 'url' => $ this -> sanitizeURL ( $ url , false , true ) , 'rawurl' => $ url ] ; curl_multi_remove_handle ( $ multicurl_resource , $ curl_instances [ $ id ] ) ; $ deadlinks [ $ url ] = $ this -> processCurlResults ( $ curlInfo , true ) ; } curl_multi_close ( $ multicurl_resource ) ; return $ deadlinks ; }
Perform a complete text request not just for headers
18,047
protected function queueRequests ( $ urls ) { $ this -> curlQueue = [ ] ; if ( $ this -> queuedTesting === false ) { $ this -> curlQueue [ ] = $ urls ; return ; } foreach ( $ urls as $ url ) { $ domain = $ this -> parseURL ( $ url ) [ 'host' ] ; $ queuedUrl = false ; $ queueIndex = - 1 ; foreach ( $ this -> curlQueue as $ queueIndex => $ urlList ) { if ( $ queuedUrl === false && ! isset ( $ urlList [ $ domain ] ) ) { $ this -> curlQueue [ $ queueIndex ] [ $ domain ] = $ url ; $ queuedUrl = true ; } } if ( $ queuedUrl === false ) { $ this -> curlQueue [ ++ $ queueIndex ] [ $ domain ] = $ url ; } } }
Queue up the URLs creating time - delays between URLs with the same domain .
18,048
protected function getCurlOptions ( $ url , $ full = false ) { $ requestType = $ this -> getRequestType ( $ url ) ; if ( $ requestType == "MMS" ) { $ url = str_ireplace ( "mms://" , "rtsp://" , $ url ) ; } $ options = [ CURLOPT_URL => $ url , CURLOPT_HEADER => 1 , CURLOPT_RETURNTRANSFER => true , CURLOPT_AUTOREFERER => true , CURLOPT_FOLLOWLOCATION => true , CURLOPT_TIMEOUT => $ this -> curlTimeoutNoBody , CURLOPT_SSL_VERIFYPEER => false , CURLOPT_COOKIEJAR => sys_get_temp_dir ( ) . "checkifdead.cookies.dat" ] ; if ( $ requestType == "RTSP" || $ requestType == "MMS" ) { $ header = [ ] ; $ options [ CURLOPT_USERAGENT ] = $ this -> mediaAgent ; } else { $ header = [ 'Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5' , 'Cache-Control: max-age=0' , 'Connection: keep-alive' , 'Keep-Alive: 300' , 'Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7' , 'Accept-Language: en-us,en;q=0.7,*;q=0.5' , 'Accept-Encoding: *' , 'Pragma: ' ] ; if ( $ this -> customUserAgent === false ) { $ options [ CURLOPT_USERAGENT ] = $ this -> userAgent ; } else { $ options [ CURLOPT_USERAGENT ] = $ this -> customUserAgent ; } } if ( $ requestType == 'FTP' ) { $ options [ CURLOPT_FTP_USE_EPRT ] = 1 ; $ options [ CURLOPT_FTP_USE_EPSV ] = 1 ; $ options [ CURLOPT_FTPSSLAUTH ] = CURLFTPAUTH_DEFAULT ; $ options [ CURLOPT_FTP_FILEMETHOD ] = CURLFTPMETHOD_SINGLECWD ; if ( $ full ) { $ options [ CURLOPT_USERPWD ] = "anonymous:anonymous@domain.com" ; } } if ( $ full ) { $ options [ CURLOPT_TIMEOUT ] = $ this -> curlTimeoutFull ; $ options [ CURLOPT_HTTPHEADER ] = $ header ; if ( $ requestType != "MMS" && $ requestType != "RTSP" ) { $ options [ CURLOPT_ENCODING ] = 'gzip,deflate' ; } $ options [ CURLOPT_USERAGENT ] = $ this -> userAgent ; } else { $ options [ CURLOPT_NOBODY ] = 1 ; } return $ options ; }
Get CURL options
18,049
protected function processCurlResults ( $ curlInfo , $ full = false ) { $ requestType = $ this -> getRequestType ( $ curlInfo [ 'url' ] ) ; $ httpCode = $ curlInfo [ 'http_code' ] ; $ effectiveUrl = $ curlInfo [ 'effective_url' ] ; $ effectiveUrlClean = $ this -> cleanURL ( $ effectiveUrl ) ; $ possibleRoots = $ this -> getDomainRoots ( $ curlInfo [ 'url' ] ) ; if ( $ httpCode >= 400 && $ httpCode < 600 ) { if ( $ full ) { $ this -> errors [ $ curlInfo [ 'rawurl' ] ] = "RESPONSE CODE: $httpCode" ; return true ; } else { return null ; } } if ( strpos ( $ effectiveUrlClean , '/404.htm' ) !== false || strpos ( $ effectiveUrlClean , '/404/' ) !== false || stripos ( $ effectiveUrlClean , 'notfound' ) !== false ) { if ( $ full ) { $ this -> errors [ $ curlInfo [ 'rawurl' ] ] = "REDIRECT TO 404" ; return true ; } else { return null ; } } if ( $ effectiveUrlClean != $ this -> cleanURL ( $ curlInfo [ 'url' ] ) ) { foreach ( $ possibleRoots as $ root ) { if ( $ root == $ effectiveUrlClean ) { $ this -> errors [ $ curlInfo [ 'rawurl' ] ] = "REDIRECT TO ROOT" ; return true ; } } } if ( in_array ( $ curlInfo [ 'curl_error' ] , $ this -> curlErrorCodes ) ) { $ this -> errors [ $ curlInfo [ 'rawurl' ] ] = "Curl Error {$curlInfo['curl_error']}: {$curlInfo['curl_error_msg']}" ; return true ; } if ( $ httpCode === 0 ) { if ( $ full ) { $ this -> errors [ $ curlInfo [ 'rawurl' ] ] = "NO RESPONSE FROM SERVER" ; return true ; } else { return null ; } } if ( $ requestType != "FTP" && ! in_array ( $ httpCode , $ this -> goodHttpCodes ) ) { $ this -> errors [ $ curlInfo [ 'rawurl' ] ] = "HTTP RESPONSE CODE: $httpCode" ; return true ; } elseif ( $ requestType == "FTP" && ! in_array ( $ httpCode , $ this -> goodFtpCodes ) ) { $ this -> errors [ $ curlInfo [ 'rawurl' ] ] = "FTP RESPONSE CODE: $httpCode" ; return true ; } return false ; }
Process the returned headers
18,050
protected function getDomainRoots ( $ url ) { $ roots = [ ] ; $ pieces = parse_url ( $ url ) ; if ( ! isset ( $ pieces [ 'host' ] , $ pieces [ 'host' ] ) ) { return [ ] ; } $ roots [ ] = $ pieces [ 'host' ] ; $ roots [ ] = $ pieces [ 'host' ] . '/' ; $ domain = isset ( $ pieces [ 'host' ] ) ? $ pieces [ 'host' ] : '' ; if ( preg_match ( '/(?P<domain>[a-z0-9][a-z0-9\-]{1,63}\.[a-z\.]{2,6})$/i' , $ domain , $ regs ) ) { $ roots [ ] = $ regs [ 'domain' ] ; $ roots [ ] = $ regs [ 'domain' ] . '/' ; } $ parts = explode ( '.' , $ pieces [ 'host' ] ) ; if ( count ( $ parts ) >= 3 ) { $ roots [ ] = implode ( '.' , array_slice ( $ parts , - 2 ) ) ; $ roots [ ] = implode ( '.' , array_slice ( $ parts , - 2 ) ) . '/' ; } return $ roots ; }
Compile an array of possible root URLs . With subdomain without subdomain etc .
18,051
public function parseURL ( $ url ) { if ( preg_match ( '/^([a-z0-9\+\-\.]*)(?:%3A%2F%2F|%3A\/\/|:%2F%2F)/i' , $ url ) ) { $ fragment = parse_url ( $ url , PHP_URL_FRAGMENT ) ; if ( ! is_null ( $ fragment ) ) { $ url = strstr ( $ url , "#" , true ) ; } $ url = rawurldecode ( $ url ) ; $ url = str_replace ( "#" , "%23" , $ url ) ; if ( ! is_null ( $ fragment ) ) { $ url .= "#$fragment" ; } } if ( preg_match ( '/^([a-z0-9\+\-\.]*:)?\/([^\/].+)/i' , $ url , $ match ) ) { $ url = $ match [ 1 ] . "//" . $ match [ 2 ] ; } if ( preg_match ( '/^:\/\/?([^\/].+)/i' , $ url , $ match ) ) { $ url = "http://" . $ match [ 1 ] ; } if ( ! preg_match ( '/(?:[a-z0-9\+\-\.]*:)?\/\//i' , $ url ) ) { $ url = "http://" . $ url ; } $ encodedUrl = preg_replace_callback ( '%[^:/@?&=#;]+%sD' , function ( $ matches ) { return urlencode ( $ matches [ 0 ] ) ; } , $ url ) ; $ parts = parse_url ( $ encodedUrl ) ; if ( $ parts !== false ) { foreach ( $ parts as $ name => $ value ) { $ parts [ $ name ] = urldecode ( $ value ) ; } } return $ parts ; }
Custom parse_url function to support UTF - 8 URLs
18,052
public function cleanURL ( $ input ) { $ url = preg_replace ( '/^((https?:|ftp:)?(\/\/))?(www\.)?/' , '' , $ input ) ; $ url = preg_replace ( '/#.*/' , '' , $ url ) ; $ url = preg_replace ( '{/$}' , '' , $ url ) ; return $ url ; }
Remove scheme www URL fragment leading forward slashes and trailing slash
18,053
public function setSiteAliasId ( int $ nb_site_alias_id ) : CNabuDataObject { if ( $ nb_site_alias_id === null ) { throw new ENabuCoreException ( ENabuCoreException :: ERROR_NULL_VALUE_NOT_ALLOWED_IN , array ( "\$nb_site_alias_id" ) ) ; } $ this -> setValue ( 'nb_site_alias_id' , $ nb_site_alias_id ) ; return $ this ; }
Sets the Site Alias Id attribute value .
18,054
public function setServerHostId ( int $ nb_server_host_id ) : CNabuDataObject { if ( $ nb_server_host_id === null ) { throw new ENabuCoreException ( ENabuCoreException :: ERROR_NULL_VALUE_NOT_ALLOWED_IN , array ( "\$nb_server_host_id" ) ) ; } $ this -> setValue ( 'nb_server_host_id' , $ nb_server_host_id ) ; return $ this ; }
Sets the Server Host Id attribute value .
18,055
public function setLastUpdateErrorCode ( int $ last_update_error_code = 0 ) : CNabuDataObject { if ( $ last_update_error_code === null ) { throw new ENabuCoreException ( ENabuCoreException :: ERROR_NULL_VALUE_NOT_ALLOWED_IN , array ( "\$last_update_error_code" ) ) ; } $ this -> setValue ( 'nb_site_alias_host_last_update_error_code' , $ last_update_error_code ) ; return $ this ; }
Sets the Site Alias Host Last Update Error Code attribute value .
18,056
public function setKey ( $ key ) { if ( $ key === null ) { throw new ENabuCoreException ( ENabuCoreException :: ERROR_NULL_VALUE_NOT_ALLOWED_IN , array ( "\$key" ) ) ; } $ this -> setValue ( "nb_http_render_descriptor_key" , $ key ) ; return $ this ; }
Sets the Descriptor key attribute value
18,057
public function setClassName ( $ class_name ) { if ( $ class_name === null ) { throw new ENabuCoreException ( ENabuCoreException :: ERROR_NULL_VALUE_NOT_ALLOWED_IN , array ( "\$class_name" ) ) ; } $ implements_list = class_implements ( $ class_name , true ) ; if ( is_array ( $ implements_list ) && array_search ( 'nabu\http\interfaces\INabuHTTPResponseRender' , $ implements_list ) ) { $ this -> setValue ( "nb_http_render_descriptor_class_name" , $ class_name ) ; } else { throw new ENabuCoreException ( ENabuCoreException :: ERROR_INVALID_RENDER_DESCRIPTOR_CLASS ) ; } return $ this ; }
Sets the Descriptor class name attribute value
18,058
protected function setAttributes ( SimpleXMLElement $ element ) { $ nb_parent = $ this -> nb_data_object -> getTranslatedObject ( ) ; if ( $ nb_parent !== null ) { $ nb_language = $ nb_parent -> getLanguage ( $ this -> nb_data_object -> getLanguageId ( ) ) ; $ element -> addAttribute ( 'lang' , $ nb_language -> grantHash ( true ) ) ; $ this -> putAttributesFromList ( $ element , array ( 'nb_site_target_section_main_image' => 'image' ) , false ) ; } }
Set default attributes of Site Target Section Language XML Element .
18,059
public function addChild ( INabuDataObjectTreeNode $ child ) { $ retval = $ this -> nb_tree_child_list -> addItem ( $ child ) ; $ child -> setParent ( $ this ) ; return $ retval ; }
Add a child if not exists . If child is in a deep level then looks for their parent level to connect both instances .
18,060
public function setChild ( INabuDataObjectTreeNode $ child ) { $ this -> nb_tree_child_list -> setItem ( $ child ) ; $ child -> setParent ( $ this ) ; return $ this ; }
Add or replaces a child . If child is in a deep level then looks for their parent level to connect both instances .
18,061
public function setParent ( INabuDataObjectTreeNode $ parent ) { $ this -> nb_tree_parent = $ parent ; if ( $ parent instanceof CNabuDataObject && method_exists ( $ parent , 'getId' ) && $ this instanceof CNabuDataObject && method_exists ( $ this , 'setParentId' ) ) { $ this -> setParentId ( $ parent -> getId ( ) ) ; } return $ this ; }
Sets the parent instance of this tree node .
18,062
private function init ( ) { $ nb_engine = CNabuEngine :: getEngine ( ) ; $ session_name = session_name ( ) ; $ nb_engine -> traceLog ( "Session Name" , $ session_name ) ; if ( array_key_exists ( $ session_name , $ _GET ) ) { $ sessid = filter_input ( INPUT_GET , $ session_name ) ; if ( preg_match ( '/^[a-zA-Z0-9]{26}$/' , $ sessid ) ) { session_id ( $ sessid ) ; $ nb_engine -> traceLog ( "Session source" , "GET" ) ; } else { $ nb_engine -> traceLog ( "Session source" , "COOKIE" ) ; } } else { $ nb_engine -> traceLog ( "Session source" , "COOKIE" ) ; } }
This method initializes the instance . Init process consists in start the session and check all objects stored in session to relink the database connection of each one .
18,063
public function applySecurityRules ( bool $ secure = false , bool $ httponly = false ) { $ nb_engine = CNabuEngine :: getEngine ( ) ; $ attrs = session_get_cookie_params ( ) ; session_set_cookie_params ( $ attrs [ 'lifetime' ] , $ attrs [ 'path' ] , $ attrs [ 'domain' ] , $ secure || $ attrs [ 'secure' ] , $ httponly || ( array_key_exists ( 'httponly' , $ attrs ) && $ attrs [ 'httponly' ] ) ) ; session_start ( ) ; $ nb_engine -> traceLog ( "Session ID" , session_id ( ) ) ; $ this -> purgeNonce ( ) ; if ( isset ( $ _SESSION ) && count ( $ _SESSION ) > 0 ) { foreach ( $ _SESSION as $ value ) { if ( $ value instanceof INabuDBObject && ! $ value -> isBuiltIn ( ) ) { $ value -> relinkDB ( ) ; } } } }
Apply requested security options to protect the session .
18,064
public function purgeNonce ( ) { $ nonce_list = $ this -> getVariable ( 'nonce_list' , array ( ) ) ; $ new_nonce_list = array ( ) ; if ( count ( $ nonce_list ) > 0 ) { $ stop_nonce = time ( ) - 1800 ; foreach ( $ nonce_list as $ key => $ word ) { if ( count ( $ word ) > 0 ) { $ this -> purgeNonceWord ( $ key , $ word , $ stop_nonce , $ new_nonce_list ) ; } } } if ( count ( $ new_nonce_list ) > 0 ) { $ this -> setVariable ( 'nonce_list' , $ new_nonce_list ) ; } else { $ this -> unsetVariable ( 'nonce_list' ) ; } }
Check Nonce storage and purge those Nonce keys that are expired .
18,065
private function purgeNonceWord ( string $ key , array $ word , int $ stop_nonce , array & $ new_nonce_list ) { foreach ( $ word as $ nonce ) { if ( $ nonce [ 'time' ] >= $ stop_nonce ) { if ( ! array_key_exists ( $ key , $ new_nonce_list ) ) { $ new_nonce_list [ $ key ] = array ( ) ; } $ new_nonce_list [ $ key ] [ ] = $ nonce ; } } }
Purge a Nonce Word list .
18,066
public function unsetVariable ( $ name ) { $ retval = false ; if ( array_key_exists ( $ name , $ _SESSION ) ) { unset ( $ _SESSION [ $ name ] ) ; $ retval = true ; } return $ retval ; }
Remove a value from the Session storage .
18,067
public function setCookie ( $ name , $ value , $ expires = null , $ path = null , $ domain = null , $ secure = false , $ httponly = false ) { if ( $ expires !== null ) { setcookie ( $ name , $ value , time ( ) + $ expires , $ path , $ domain , $ secure , $ httponly ) ; } else { setcookie ( $ name , $ value , 0 , $ path , $ domain , $ secure , $ httponly ) ; } }
Sets or updates a Cookie
18,068
public function validateEmbeddedClass ( $ class , $ classAnnotations ) { $ check = false ; foreach ( $ classAnnotations as $ annotation ) { if ( $ annotation instanceof \ ProAI \ Datamapper \ Annotations \ Embeddable ) { $ check = true ; } } if ( ! $ check ) { throw new InvalidArgumentException ( 'Embedded class ' . $ class . ' has no @Embeddable annotation.' ) ; } }
Check if class exists .
18,069
public function validateName ( $ name , $ definedClass ) { if ( $ name != camel_case ( $ name ) ) { throw new Exception ( 'Name "' . $ name . '" (defined in class "' . $ definedClass . '") is not a camel case name.' ) ; } return true ; }
Check if name is not snake case .
18,070
public function validatePrimaryKey ( EntityDefinition $ entityMetadata ) { $ countPrimaryKeys = 0 ; foreach ( $ entityMetadata [ 'table' ] [ 'columns' ] as $ column ) { if ( ! empty ( $ column [ 'primary' ] ) ) { $ countPrimaryKeys ++ ; } } if ( $ countPrimaryKeys == 0 ) { throw new DomainException ( 'No primary key defined in class ' . $ entityMetadata [ 'class' ] . '.' ) ; } elseif ( $ countPrimaryKeys > 1 ) { throw new DomainException ( 'No composite primary keys allowed for class ' . $ entityMetadata [ 'class' ] . '.' ) ; } }
Validate the number of primary keys .
18,071
public function validateTimestamps ( EntityDefinition $ entityMetadata ) { $ columnNames = [ ] ; foreach ( $ entityMetadata [ 'table' ] [ 'columns' ] as $ column ) { $ columnNames [ ] = $ column [ 'name' ] ; } if ( ! empty ( $ entityMetadata [ 'versionTable' ] ) ) { foreach ( $ entityMetadata [ 'versionTable' ] [ 'columns' ] as $ column ) { $ columnNames [ ] = $ column [ 'name' ] ; } } if ( ! in_array ( 'created_at' , $ columnNames ) || ! in_array ( 'updated_at' , $ columnNames ) ) { throw new DomainException ( '@Timestamps annotation defined in class ' . $ entityMetadata [ 'class' ] . ' requires a $createdAt and an $updatedAt column property.' ) ; } }
Validate the timestamps columns .
18,072
public function validateVersionTable ( EntityDefinition $ entityMetadata ) { $ columnNames = [ ] ; $ countPrimaryKeys = 0 ; $ versionPrimaryKey = false ; foreach ( $ entityMetadata [ 'table' ] [ 'columns' ] as $ column ) { $ columnNames [ ] = $ column [ 'name' ] ; } if ( ! in_array ( 'latest_version' , $ columnNames ) ) { throw new DomainException ( '@Versionable annotation defined in class ' . $ entityMetadata [ 'class' ] . ' requires a $latestVersion column property.' ) ; } $ columnNames = [ ] ; foreach ( $ entityMetadata [ 'versionTable' ] [ 'columns' ] as $ column ) { $ columnNames [ ] = $ column [ 'name' ] ; if ( ! empty ( $ column [ 'primary' ] ) ) { $ countPrimaryKeys ++ ; } if ( ! empty ( $ column [ 'primary' ] ) && $ column [ 'name' ] == 'version' ) { $ versionPrimaryKey = true ; } } if ( ! in_array ( 'version' , $ columnNames ) || ! $ versionPrimaryKey ) { throw new DomainException ( '@Versionable annotation defined in class ' . $ entityMetadata [ 'class' ] . ' requires a $version property column, which is a primary key.' ) ; } if ( $ countPrimaryKeys > 2 ) { throw new DomainException ( 'No more than 2 primary keys are allowed for version table in class ' . $ entityMetadata [ 'class' ] . '.' ) ; } }
Validate the version table .
18,073
public function validatePivotTables ( $ metadata ) { $ pivotTables = [ ] ; foreach ( $ metadata as $ entityMetadata ) { foreach ( $ entityMetadata [ 'relations' ] as $ relationMetadata ) { if ( ! empty ( $ relationMetadata [ 'pivotTable' ] ) ) { $ pivotTables [ $ entityMetadata [ 'class' ] . $ relationMetadata [ 'relatedEntity' ] ] = $ relationMetadata ; if ( isset ( $ pivotTables [ $ relationMetadata [ 'relatedEntity' ] . $ entityMetadata [ 'class' ] ] ) ) { $ relation1 = $ pivotTables [ $ relationMetadata [ 'relatedEntity' ] . $ entityMetadata [ 'class' ] ] ; $ relation2 = $ relationMetadata ; $ error = null ; if ( $ relation1 [ 'pivotTable' ] [ 'name' ] != $ relation2 [ 'pivotTable' ] [ 'name' ] ) { $ error = 'Different table names (compared ' . $ relation1 [ 'pivotTable' ] [ 'name' ] . ' with ' . $ relation2 [ 'pivotTable' ] [ 'name' ] . ').' ; } if ( ! empty ( array_diff_key ( $ relation1 [ 'pivotTable' ] [ 'columns' ] , $ relation2 [ 'pivotTable' ] [ 'columns' ] ) ) ) { $ columns1 = implode ( ', ' , array_keys ( $ relation1 [ 'pivotTable' ] [ 'columns' ] ) ) ; $ columns2 = implode ( ', ' , array_keys ( $ relation2 [ 'pivotTable' ] [ 'columns' ] ) ) ; $ error = 'Different column names (compared ' . $ columns1 . ' with ' . $ columns2 . ').' ; } if ( $ error ) { throw new DomainException ( 'Error syncing pivot tables for relations "' . $ relation1 [ 'name' ] . '" in "' . $ relation2 [ 'relatedEntity' ] . '" and "' . $ relation2 [ 'name' ] . '" in "' . $ relation1 [ 'relatedEntity' ] . '": ' . $ error ) ; } } } } } }
Check if pivot tables of bi - directional relations are identically .
18,074
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 ; }
Sets the Medioteca Item Id attribute value .
18,075
public function setHavePublic ( $ have_public ) : CNabuDataObject { if ( $ have_public === null ) { throw new ENabuCoreException ( ENabuCoreException :: ERROR_NULL_VALUE_NOT_ALLOWED_IN , array ( "\$have_public" ) ) ; } $ this -> setValue ( 'nb_medioteca_item_lang_have_public' , $ have_public ) ; return $ this ; }
Sets the Medioteca Item Lang Have Public attribute value .
18,076
protected function discoverInterface ( ) : bool { if ( ! ( $ this -> nb_interface instanceof INabuProviderInterface ) && ( $ nb_manager = $ this -> nb_descriptor -> getManager ( ) ) instanceof INabuProviderManager ) { $ this -> nb_interface = $ this -> createInterface ( $ nb_manager , $ this -> nb_descriptor ) ; } return ( $ this -> nb_interface instanceof INabuProviderInterface ) ; }
Discover the Render Transform Interface .
18,077
public function setRequest ( CNabuHTTPRequest $ nb_request ) : CNabuProviderInterfaceFactoryAdapter { if ( $ this -> discoverInterface ( ) ) { $ this -> nb_interface -> setRequest ( $ nb_request ) ; } else { throw new ENabuProviderException ( ENabuProviderException :: ERROR_INTERFACE_NOT_SETTED ) ; } return $ this ; }
Pass Request instance to managed interface .
18,078
public function setResponse ( CNabuHTTPResponse $ nb_response = null ) : CNabuProviderInterfaceFactoryAdapter { if ( $ this -> discoverInterface ( ) ) { $ this -> nb_interface -> setResponse ( $ nb_response ) ; } else { throw new ENabuProviderException ( ENabuProviderException :: ERROR_INTERFACE_NOT_SETTED ) ; } return $ this ; }
Pass Response instance to managed interface .
18,079
public function collect ( SimpleXMLElement $ element ) { if ( $ element -> getName ( ) === get_called_class ( ) :: getTagName ( ) && $ this -> locateDataObject ( $ element ) ) { $ this -> getAttributes ( $ element ) ; $ this -> getChilds ( $ element ) ; } else { throw new ENabuXMLException ( ENabuXMLException :: ERROR_UNEXPECTED_ELEMENT , array ( $ element -> getName ( ) ) ) ; } }
Collects data from a XML branch .
18,080
public static function driver ( string $ name ) { $ name = explode ( ':' , $ name ) ; $ class = "\\NonDB\\Drivers\\" . $ name [ 0 ] ; $ param = $ name [ 1 ] ; if ( ! class_exists ( $ class ) || ! ( \ NonDB \ Components \ Tool :: checkImplement ( $ class , "NonDB\\Interfaces\\Driver" ) ) ) { throw new \ NonDB \ Exceptions \ CoreException ( "Driver $class wasn't exists." , "0011" ) ; return false ; } $ driver = eval ( "return new $class(urldecode(\$param));" ) ; return $ driver ; }
Create a driver
18,081
protected function getAttributesFromList ( SimpleXMLElement $ element , array $ attributes , bool $ ignore_empty = false ) : int { $ count = 0 ; if ( count ( $ attributes ) > 0 ) { foreach ( $ attributes as $ field => $ attr ) { if ( isset ( $ element [ $ attr ] ) ) { $ value = ( string ) $ element [ $ attr ] ; if ( $ ignore_empty || strlen ( $ value ) > 0 ) { $ this -> nb_data_object -> setValue ( $ field , $ value ) ; $ count ++ ; } } } } return $ count ; }
Get a group of attributes listed in an array .
18,082
protected function putAttributesFromList ( SimpleXMLElement $ element , array $ attributes , bool $ ignore_empty = false ) : int { $ count = 0 ; if ( count ( $ attributes ) > 0 ) { foreach ( $ attributes as $ field => $ attr ) { if ( $ this -> nb_data_object -> contains ( $ field ) && ( ! $ ignore_empty || ! $ this -> nb_data_object -> isValueNull ( $ field ) || ! $ this -> nb_data_object -> isValueEmptyString ( $ field ) ) ) { $ element -> addAttribute ( $ attr , $ this -> nb_data_object -> getValue ( $ field ) ) ; $ count ++ ; } } } return $ count ; }
Set a group of attributes listed in an array .
18,083
protected function putChildsAsCDATAFromList ( SimpleXMLElement $ element , array $ childs , bool $ ignore_empty = false ) : int { $ count = 0 ; if ( count ( $ childs ) > 0 ) { foreach ( $ childs as $ field => $ child ) { if ( $ this -> nb_data_object -> contains ( $ field ) && ( ! $ ignore_empty || ! $ this -> nb_data_object -> isValueNull ( $ field ) || ! $ this -> nb_data_object -> isValueEmptyString ( $ field ) ) ) { $ element -> addChild ( $ child , $ this -> packCDATA ( $ this -> nb_data_object -> getValue ( $ field ) ) ) ; $ count ++ ; } } } return $ count ; }
Set a group of childs listed in an array as Element > CDATA structure .
18,084
public function getAll ( array $ queryParams = [ ] ) { $ response = $ this -> api -> applications ( ) -> scans ( ) -> issues ( ) -> types ( ) -> patches ( ) -> getAll ( $ queryParams ) ; return new PatchesResponse ( $ response ) ; }
Get all patches for issue types
18,085
public function getById ( $ patchId , array $ queryParams = [ ] ) { $ response = $ this -> api -> applications ( ) -> scans ( ) -> issues ( ) -> types ( ) -> patches ( ) -> getById ( $ patchId , $ queryParams ) ; return new PatchResponse ( $ response ) ; }
Get patch for issue types by id
18,086
public static function hydrateCollection ( array $ languages ) { $ hydrated = [ ] ; foreach ( $ languages as $ language ) { $ hydrated [ ] = self :: hydrate ( $ language ) ; } return $ hydrated ; }
Hydrate a collection of language objects into a collection of LanguageEntity objects
18,087
public static function hydrate ( stdClass $ language ) { $ hydrated = new LanguageEntity ( ) ; if ( isset ( $ language -> id ) ) { $ hydrated -> setId ( $ language -> id ) ; } if ( isset ( $ language -> name ) ) { $ hydrated -> setName ( $ language -> name ) ; } if ( isset ( $ language -> file_extensions ) ) { $ hydrated -> setFileExtensions ( $ language -> file_extensions ) ; } if ( isset ( $ language -> config_file_extensions ) ) { $ hydrated -> setConfigFileExtensions ( $ language -> config_file_extensions ) ; } return $ hydrated ; }
Hydrate a language object into a LanguageEntity object
18,088
public function getRole ( $ force = false ) { if ( $ this -> nb_role === null || $ force ) { $ this -> nb_role = null ; if ( $ this -> isValueNumeric ( 'nb_role_id' ) ) { $ nb_role = new CNabuRole ( $ this ) ; if ( $ nb_role -> isFetched ( ) ) { $ this -> nb_role = $ nb_role ; } } } return $ this -> nb_role ; }
Gets the Role instance .
18,089
public function setRole ( CNabuRole $ nb_role ) { $ this -> nb_role = $ nb_role ; if ( $ this instanceof CNabuDataObject ) { $ this -> transferValue ( $ nb_role , NABU_ROLE_FIELD_ID ) ; } return $ this ; }
Sets the Role instance that owns this object and sets the field containing the Role id .
18,090
public static function postPackageInstall ( PackageEvent $ event ) { $ installedPackage = $ event -> getOperation ( ) -> getPackage ( ) -> getName ( ) ; if ( self :: checkConfig ( $ event , $ installedPackage ) ) { self :: phinxMigrateFromPackageName ( $ event , $ installedPackage , true ) ; } else { die ( ) ; } }
post - package - install
18,091
public static function postPackageUpdate ( PackageEvent $ event ) { $ installedPackage = $ event -> getOperation ( ) -> getTargetPackage ( ) -> getName ( ) ; if ( self :: checkConfig ( $ event , $ installedPackage ) ) { self :: phinxMigrateFromPackageName ( $ event , $ installedPackage ) ; } else { die ( ) ; } }
post - package - update
18,092
public static function prePackageUninstall ( PackageEvent $ event ) { $ installedPackage = $ event -> getOperation ( ) -> getPackage ( ) -> getName ( ) ; if ( self :: checkConfig ( $ event , $ installedPackage ) ) { self :: phinxRollbackFromPackageName ( $ event , $ installedPackage ) ; } else { die ( ) ; } }
pre - package - uninstall
18,093
protected function replaceBreadcrumb ( $ modelName , $ modelLabel ) { $ this -> stub = str_replace ( '{{breadcrumb}}' , ucfirst ( strtolower ( $ modelLabel ) ) , $ this -> stub ) ; $ this -> stub = str_replace ( '{{breadcrumb_lw}}' , strtolower ( $ modelName ) , $ this -> stub ) ; return $ this ; }
Replace the breadcrumb .
18,094
public function offsetSet ( $ key , $ newval ) { if ( $ def = in_array ( $ key , array_keys ( $ this -> keys ) ) ) { parent :: offsetSet ( $ key , $ newval ) ; } else { throw new UnexpectedValueException ( $ key . ' is not defined in metadata definition ' . get_class ( $ this ) . '.' ) ; } }
Do not allow to set more definitions .
18,095
public function authenticate ( Request $ request , Route $ route ) { if ( ! $ user = $ this -> auth -> user ( ) ) { throw new UnauthorizedHttpException ( get_class ( $ this ) , 'Unable to authenticate with invalid API key and token.' ) ; } return $ user ; }
Authenticate request with a Illuminate Guard .
18,096
public static function hydrateCollection ( array $ organizations ) { $ hydrated = [ ] ; foreach ( $ organizations as $ organization ) { $ hydrated [ ] = self :: hydrate ( $ organization ) ; } return $ hydrated ; }
Hydrate a collection of organization objects into a collection of OrgEntity objects
18,097
public static function hydrate ( stdClass $ organization ) { $ hydrated = new OrgEntity ( ) ; if ( isset ( $ organization -> id ) ) { $ hydrated -> setId ( $ organization -> id ) ; } if ( isset ( $ organization -> name ) ) { $ hydrated -> setName ( $ organization -> name ) ; } if ( isset ( $ organization -> valid_until ) ) { $ hydrated -> setValidUntil ( new DateTime ( $ organization -> valid_until ) ) ; } if ( isset ( $ organization -> quotas ) && is_array ( $ organization -> quotas ) ) { $ hydrated -> setQuotas ( QuotaHydrator :: hydrateCollection ( $ organization -> quotas ) ) ; } if ( isset ( $ organization -> trial_issue_types ) && is_array ( $ organization -> trial_issue_types ) ) { $ hydrated -> setTrialIssueTypes ( TypeHydrator :: hydrateCollection ( $ organization -> trial_issue_types ) ) ; } if ( isset ( $ organization -> disabled ) ) { $ hydrated -> setDisabled ( $ organization -> disabled ) ; } return $ hydrated ; }
Hydrate a organization object into a OrgEntity object
18,098
public function enableLanguage ( $ ISO639_1 , $ name , $ default_country_code , $ default_lang = false ) { $ nb_language = new CNabuBuiltInLanguage ( ) ; $ nb_language -> setISO6391 ( $ ISO639_1 ) -> setName ( $ name ) -> setDefaultCountryCode ( $ default_country_code ) -> setEnabled ( CNabuLanguage :: LANGUAGE_ENABLED ) ; $ nb_site = $ this -> nb_engine -> getHTTPServer ( ) -> getSite ( ) ; $ nb_site -> setLanguage ( $ nb_language ) ; if ( $ default_lang ) { $ nb_site -> setDefaultLanguage ( $ nb_language ) ; } return $ nb_language ; }
Fast method to add a language to the Site .
18,099
public function addSmartyTarget ( $ display , $ content , $ default = false ) { $ target = new CNabuBuiltInSiteTarget ( ) ; $ target -> setMIMETypeId ( 'text/html' ) -> setOutputTypeHTML ( ) -> setSmartyDisplayFile ( $ display ) -> setSmartyContentFile ( $ content ) ; return $ this -> addTarget ( $ target , $ default ) ; }
Add a target using Smarty template files