Skip to content

Commit a679a13

Browse files
authored
New fetch function to access eZSiteData in templates (#35)
* New fetch function to access eZSiteData in templates * Code formatting * Fixing spacing
1 parent 54c9fd9 commit a679a13

File tree

3 files changed

+24
-5
lines changed

3 files changed

+24
-5
lines changed

kernel/classes/ezsitedata.php

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public static function definition()
4949
* Constructs a new eZSiteData instance. You need to call 'store()'
5050
* in order to store it into the DB.
5151
*
52-
* @param string $key
52+
* @param string $name
5353
* @param string $value
5454
* @return eZSiteData
5555
*/
@@ -63,14 +63,13 @@ public static function create( $name, $value )
6363

6464
/**
6565
* Fetches a site data by name
66-
*
66+
*
6767
* @param string $name
68-
* @return eZPersistentObject
68+
* @return eZSiteData
6969
*/
7070
public static function fetchByName( $name )
7171
{
72-
$result = parent::fetchObject( self::definition(), null, array( 'name' => $name ) );
73-
return $result;
72+
return parent::fetchObject( self::definition(), null, array( 'name' => $name ) );
7473
}
7574

7675
}

kernel/content/ezcontentfunctioncollection.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1534,6 +1534,17 @@ static public function fetchContentTreeMenuExpiry()
15341534

15351535
return array( 'result' => $expiryHandler->timestamp( 'content-tree-menu' ) );
15361536
}
1537+
1538+
/**
1539+
* Fetches an eZSiteData instance if it exists in the database.
1540+
*
1541+
* @param string $name
1542+
* @return array
1543+
*/
1544+
static public function fetchSiteData( $name )
1545+
{
1546+
return array( 'result' => eZSiteData::fetchByName( $name ) );
1547+
}
15371548
}
15381549

15391550
?>

kernel/content/function_definition.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1222,4 +1222,13 @@
12221222
'parameter_type' => 'standard',
12231223
'parameters' => array() );
12241224

1225+
$FunctionList['site_data'] = array( 'name' => 'site_data',
1226+
'operation_types' => array( 'read' ),
1227+
'call_method' => array( 'class' => 'eZContentFunctionCollection',
1228+
'method' => 'fetchSiteData' ),
1229+
'parameter_type' => 'standard',
1230+
'parameters' => array( array( 'name' => 'name',
1231+
'type' => 'string',
1232+
'required' => true ) ) );
1233+
12251234
?>

0 commit comments

Comments
 (0)