repo stringlengths 6 63 | path stringlengths 5 140 | func_name stringlengths 3 151 | original_string stringlengths 84 13k | language stringclasses 1 value | code stringlengths 84 13k | code_tokens list | docstring stringlengths 3 47.2k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 91 247 | partition stringclasses 1 value |
|---|---|---|---|---|---|---|---|---|---|---|---|
baidubce/bce-sdk-php | src/BaiduBce/Services/Lss/LssClient.php | LssClient.getPreset | public function getPreset($name, $options = array())
{
list($config) = $this->parseOptions($options, 'config');
if (empty($name)) {
throw new BceClientException("The parameter name "
. "should NOT be null or empty string");
}
return $this->sendRequest(
HttpMethod::GET,
array(
'config' => $config,
),
"/preset/$name"
);
} | php | public function getPreset($name, $options = array())
{
list($config) = $this->parseOptions($options, 'config');
if (empty($name)) {
throw new BceClientException("The parameter name "
. "should NOT be null or empty string");
}
return $this->sendRequest(
HttpMethod::GET,
array(
'config' => $config,
),
"/preset/$name"
);
} | [
"public",
"function",
"getPreset",
"(",
"$",
"name",
",",
"$",
"options",
"=",
"array",
"(",
")",
")",
"{",
"list",
"(",
"$",
"config",
")",
"=",
"$",
"this",
"->",
"parseOptions",
"(",
"$",
"options",
",",
"'config'",
")",
";",
"if",
"(",
"empty",... | Get a preset.
@param $name string, preset name
@param array $options Supported options:
{
config: the optional bce configuration, which will overwrite the
default client configuration that was passed in constructor.
}
@return mixed preset detail
@throws BceClientException | [
"Get",
"a",
"preset",
"."
] | c3164434c8f0fe53b6ffe4479def893465137282 | https://github.com/baidubce/bce-sdk-php/blob/c3164434c8f0fe53b6ffe4479def893465137282/src/BaiduBce/Services/Lss/LssClient.php#L827-L843 | train |
baidubce/bce-sdk-php | src/BaiduBce/Services/Lss/LssClient.php | LssClient.deletePreset | public function deletePreset($name, $options = array())
{
list($config) = $this->parseOptions($options, 'config');
if (empty($name)) {
throw new BceClientException("The parameter name "
. "should NOT be null or empty string");
}
return $this->sendRequest(
HttpMethod::DELETE,
array(
'config' => $config,
),
"/preset/$name"
);
} | php | public function deletePreset($name, $options = array())
{
list($config) = $this->parseOptions($options, 'config');
if (empty($name)) {
throw new BceClientException("The parameter name "
. "should NOT be null or empty string");
}
return $this->sendRequest(
HttpMethod::DELETE,
array(
'config' => $config,
),
"/preset/$name"
);
} | [
"public",
"function",
"deletePreset",
"(",
"$",
"name",
",",
"$",
"options",
"=",
"array",
"(",
")",
")",
"{",
"list",
"(",
"$",
"config",
")",
"=",
"$",
"this",
"->",
"parseOptions",
"(",
"$",
"options",
",",
"'config'",
")",
";",
"if",
"(",
"empt... | Delete a preset.
@param $name string, preset name
@param array $options Supported options:
{
config: the optional bce configuration, which will overwrite the
default client configuration that was passed in constructor.
}
@return mixed
@throws BceClientException | [
"Delete",
"a",
"preset",
"."
] | c3164434c8f0fe53b6ffe4479def893465137282 | https://github.com/baidubce/bce-sdk-php/blob/c3164434c8f0fe53b6ffe4479def893465137282/src/BaiduBce/Services/Lss/LssClient.php#L881-L897 | train |
baidubce/bce-sdk-php | src/BaiduBce/Services/Lss/LssClient.php | LssClient.listNotifications | public function listNotifications($options = array())
{
list($config) = $this->parseOptions($options, 'config');
return $this->sendRequest(
HttpMethod::GET,
array(
'config' => $config,
),
'/notification'
);
} | php | public function listNotifications($options = array())
{
list($config) = $this->parseOptions($options, 'config');
return $this->sendRequest(
HttpMethod::GET,
array(
'config' => $config,
),
'/notification'
);
} | [
"public",
"function",
"listNotifications",
"(",
"$",
"options",
"=",
"array",
"(",
")",
")",
"{",
"list",
"(",
"$",
"config",
")",
"=",
"$",
"this",
"->",
"parseOptions",
"(",
"$",
"options",
",",
"'config'",
")",
";",
"return",
"$",
"this",
"->",
"s... | List notifications.
@param array $options Supported options:
{
config: the optional bce configuration, which will overwrite the
default client configuration that was passed in constructor.
}
@return mixed notification list | [
"List",
"notifications",
"."
] | c3164434c8f0fe53b6ffe4479def893465137282 | https://github.com/baidubce/bce-sdk-php/blob/c3164434c8f0fe53b6ffe4479def893465137282/src/BaiduBce/Services/Lss/LssClient.php#L980-L991 | train |
baidubce/bce-sdk-php | src/BaiduBce/Services/Lss/LssClient.php | LssClient.createImageWatermark | public function createImageWatermark($name, $content, $options = array())
{
list($config, $maxWidthInPixel, $maxHeightInPixel,
$sizingPolicy, $verticalAlignment, $horizontalAlignment,
$verticalOffsetInPixel, $horizontalOffsetInPixel) = $this->parseOptions(
$options,
'config',
'maxWidthInPixel',
'maxHeightInPixel',
'sizingPolicy',
'verticalAlignment',
'horizontalAlignment',
'verticalOffsetInPixel',
'horizontalOffsetInPixel'
);
if (empty($name)) {
throw new BceClientException("The parameter name "
. "should NOT be null or empty string");
}
if (empty($content)) {
throw new BceClientException("The parameter content "
. "should NOT be null or empty string");
}
$body = array(
'name' => $name,
'content' => $content,
);
$size = array();
if ($maxWidthInPixel !== null) {
$size['maxWidthInPixel'] = $maxWidthInPixel;
}
if ($maxHeightInPixel !== null) {
$size['maxHeightInPixel'] = $maxHeightInPixel;
}
if ($sizingPolicy !== null) {
$size['sizingPolicy'] = $sizingPolicy;
}
if (count($size) > 0) {
$body['size'] = $size;
}
$position = array();
if ($verticalAlignment !== null) {
$position['verticalAlignment'] = $verticalAlignment;
}
if ($horizontalAlignment !== null) {
$position['horizontalAlignment'] = $horizontalAlignment;
}
if ($verticalOffsetInPixel !== null) {
$position['verticalOffsetInPixel'] = $verticalOffsetInPixel;
}
if ($horizontalOffsetInPixel !== null) {
$position['horizontalOffsetInPixel'] = $horizontalOffsetInPixel;
}
if (count($position) > 0) {
$body['position'] = $position;
}
return $this->sendRequest(
HttpMethod::POST,
array(
'config' => $config,
'body' => json_encode($body, JSON_FORCE_OBJECT),
),
"/watermark/image"
);
} | php | public function createImageWatermark($name, $content, $options = array())
{
list($config, $maxWidthInPixel, $maxHeightInPixel,
$sizingPolicy, $verticalAlignment, $horizontalAlignment,
$verticalOffsetInPixel, $horizontalOffsetInPixel) = $this->parseOptions(
$options,
'config',
'maxWidthInPixel',
'maxHeightInPixel',
'sizingPolicy',
'verticalAlignment',
'horizontalAlignment',
'verticalOffsetInPixel',
'horizontalOffsetInPixel'
);
if (empty($name)) {
throw new BceClientException("The parameter name "
. "should NOT be null or empty string");
}
if (empty($content)) {
throw new BceClientException("The parameter content "
. "should NOT be null or empty string");
}
$body = array(
'name' => $name,
'content' => $content,
);
$size = array();
if ($maxWidthInPixel !== null) {
$size['maxWidthInPixel'] = $maxWidthInPixel;
}
if ($maxHeightInPixel !== null) {
$size['maxHeightInPixel'] = $maxHeightInPixel;
}
if ($sizingPolicy !== null) {
$size['sizingPolicy'] = $sizingPolicy;
}
if (count($size) > 0) {
$body['size'] = $size;
}
$position = array();
if ($verticalAlignment !== null) {
$position['verticalAlignment'] = $verticalAlignment;
}
if ($horizontalAlignment !== null) {
$position['horizontalAlignment'] = $horizontalAlignment;
}
if ($verticalOffsetInPixel !== null) {
$position['verticalOffsetInPixel'] = $verticalOffsetInPixel;
}
if ($horizontalOffsetInPixel !== null) {
$position['horizontalOffsetInPixel'] = $horizontalOffsetInPixel;
}
if (count($position) > 0) {
$body['position'] = $position;
}
return $this->sendRequest(
HttpMethod::POST,
array(
'config' => $config,
'body' => json_encode($body, JSON_FORCE_OBJECT),
),
"/watermark/image"
);
} | [
"public",
"function",
"createImageWatermark",
"(",
"$",
"name",
",",
"$",
"content",
",",
"$",
"options",
"=",
"array",
"(",
")",
")",
"{",
"list",
"(",
"$",
"config",
",",
"$",
"maxWidthInPixel",
",",
"$",
"maxHeightInPixel",
",",
"$",
"sizingPolicy",
"... | Create a image watermark.
@param $name string, image watermark name
@param $content string, watermark image base64 encode
@param array $options Supported options:
{
config: the optional bce configuration, which will overwrite the
default client configuration that was passed in constructor.
maxWidthInPixel: number, watermark maximum width in pixel
maxHeightInPixel: number, watermark maximum Height in pixel
sizingPolicy: string, watermark size retractable policy
verticalAlignment: string, vertically aligned manner
horizontalAlignment: string, horizontal aligned manner
verticalOffsetInPixel: number, vertical offset in pixel
horizontalOffsetInPixel: number, horizontal offset in pixel
}
@return mixed
@throws BceClientException | [
"Create",
"a",
"image",
"watermark",
"."
] | c3164434c8f0fe53b6ffe4479def893465137282 | https://github.com/baidubce/bce-sdk-php/blob/c3164434c8f0fe53b6ffe4479def893465137282/src/BaiduBce/Services/Lss/LssClient.php#L1147-L1216 | train |
baidubce/bce-sdk-php | src/BaiduBce/Services/Lss/LssClient.php | LssClient.createTimestampWatermark | public function createTimestampWatermark($name, $options = array())
{
list($config, $timezone, $alpha, $fontFamily, $fontSizeInPoint,
$fontColor, $backgroundColor, $verticalAlignment, $horizontalAlignment,
$verticalOffsetInPixel, $horizontalOffsetInPixel) = $this->parseOptions(
$options,
'config',
'timezone',
'alpha',
'fontFamily',
'fontSizeInPoint',
'fontColor',
'backgroundColor',
'verticalAlignment',
'horizontalAlignment',
'verticalOffsetInPixel',
'horizontalOffsetInPixel'
);
if (empty($name)) {
throw new BceClientException("The parameter name "
. "should NOT be null or empty string");
}
$body = array(
'name' => $name,
);
if ($timezone !== null) {
$body['timezone'] = $timezone;
}
if ($alpha !== null) {
$body['alpha'] = $alpha;
}
$font = array();
if ($fontFamily !== null) {
$font['family'] = $fontFamily;
}
if ($fontSizeInPoint !== null) {
$font['sizeInPoint'] = $fontSizeInPoint;
}
if ($fontColor !== null) {
$font['color'] = $fontColor;
}
if (count($font) > 0) {
$body['font'] = $font;
}
$background = array();
if ($backgroundColor !== null) {
$background['color'] = $backgroundColor;
$body['background'] = $background;
}
$position = array();
if ($verticalAlignment !== null) {
$position['verticalAlignment'] = $verticalAlignment;
}
if ($horizontalAlignment !== null) {
$position['horizontalAlignment'] = $horizontalAlignment;
}
if ($verticalOffsetInPixel !== null) {
$position['verticalOffsetInPixel'] = $verticalOffsetInPixel;
}
if ($horizontalOffsetInPixel !== null) {
$position['horizontalOffsetInPixel'] = $horizontalOffsetInPixel;
}
if (count($position) > 0) {
$body['position'] = $position;
}
return $this->sendRequest(
HttpMethod::POST,
array(
'config' => $config,
'body' => json_encode($body, JSON_FORCE_OBJECT),
),
"/watermark/timestamp"
);
} | php | public function createTimestampWatermark($name, $options = array())
{
list($config, $timezone, $alpha, $fontFamily, $fontSizeInPoint,
$fontColor, $backgroundColor, $verticalAlignment, $horizontalAlignment,
$verticalOffsetInPixel, $horizontalOffsetInPixel) = $this->parseOptions(
$options,
'config',
'timezone',
'alpha',
'fontFamily',
'fontSizeInPoint',
'fontColor',
'backgroundColor',
'verticalAlignment',
'horizontalAlignment',
'verticalOffsetInPixel',
'horizontalOffsetInPixel'
);
if (empty($name)) {
throw new BceClientException("The parameter name "
. "should NOT be null or empty string");
}
$body = array(
'name' => $name,
);
if ($timezone !== null) {
$body['timezone'] = $timezone;
}
if ($alpha !== null) {
$body['alpha'] = $alpha;
}
$font = array();
if ($fontFamily !== null) {
$font['family'] = $fontFamily;
}
if ($fontSizeInPoint !== null) {
$font['sizeInPoint'] = $fontSizeInPoint;
}
if ($fontColor !== null) {
$font['color'] = $fontColor;
}
if (count($font) > 0) {
$body['font'] = $font;
}
$background = array();
if ($backgroundColor !== null) {
$background['color'] = $backgroundColor;
$body['background'] = $background;
}
$position = array();
if ($verticalAlignment !== null) {
$position['verticalAlignment'] = $verticalAlignment;
}
if ($horizontalAlignment !== null) {
$position['horizontalAlignment'] = $horizontalAlignment;
}
if ($verticalOffsetInPixel !== null) {
$position['verticalOffsetInPixel'] = $verticalOffsetInPixel;
}
if ($horizontalOffsetInPixel !== null) {
$position['horizontalOffsetInPixel'] = $horizontalOffsetInPixel;
}
if (count($position) > 0) {
$body['position'] = $position;
}
return $this->sendRequest(
HttpMethod::POST,
array(
'config' => $config,
'body' => json_encode($body, JSON_FORCE_OBJECT),
),
"/watermark/timestamp"
);
} | [
"public",
"function",
"createTimestampWatermark",
"(",
"$",
"name",
",",
"$",
"options",
"=",
"array",
"(",
")",
")",
"{",
"list",
"(",
"$",
"config",
",",
"$",
"timezone",
",",
"$",
"alpha",
",",
"$",
"fontFamily",
",",
"$",
"fontSizeInPoint",
",",
"$... | Create a timestamp watermark.
@param $name string, image watermark name
@param array $options Supported options:
{
config: the optional bce configuration, which will overwrite the
default client configuration that was passed in constructor.
timezone: string, timestamp time zone
alpha: number, timestamp watermark transparency
fontFamily: string, timestamp watermark fonts
fontSizeInPoint: number, font size in point
fontColor: string, timestamp watermark font color
backgroundColor: string, background color
verticalAlignment: string, vertically aligned manner
horizontalAlignment: string, horizontal aligned manner
verticalOffsetInPixel: number, vertical offset in pixel
horizontalOffsetInPixel: number, horizontal offset in pixel
}
@return mixed
@throws BceClientException | [
"Create",
"a",
"timestamp",
"watermark",
"."
] | c3164434c8f0fe53b6ffe4479def893465137282 | https://github.com/baidubce/bce-sdk-php/blob/c3164434c8f0fe53b6ffe4479def893465137282/src/BaiduBce/Services/Lss/LssClient.php#L1323-L1403 | train |
baidubce/bce-sdk-php | src/BaiduBce/Services/Lss/LssClient.php | LssClient.getStream | public function getStream($domain, $app, $stream, $options = array())
{
list($config) = $this->parseOptions($options, 'config');
if (empty($domain)) {
throw new BceClientException("The parameter domain "
. "should NOT be null or empty string");
}
if (empty($app)) {
throw new BceClientException("The parameter app "
. "should NOT be null or empty string");
}
if (empty($stream)) {
throw new BceClientException("The parameter stream "
. "should NOT be null or empty string");
}
return $this->sendRequest(
HttpMethod::GET,
array(
'config' => $config,
),
"/domain/$domain/app/$app/stream/$stream"
);
} | php | public function getStream($domain, $app, $stream, $options = array())
{
list($config) = $this->parseOptions($options, 'config');
if (empty($domain)) {
throw new BceClientException("The parameter domain "
. "should NOT be null or empty string");
}
if (empty($app)) {
throw new BceClientException("The parameter app "
. "should NOT be null or empty string");
}
if (empty($stream)) {
throw new BceClientException("The parameter stream "
. "should NOT be null or empty string");
}
return $this->sendRequest(
HttpMethod::GET,
array(
'config' => $config,
),
"/domain/$domain/app/$app/stream/$stream"
);
} | [
"public",
"function",
"getStream",
"(",
"$",
"domain",
",",
"$",
"app",
",",
"$",
"stream",
",",
"$",
"options",
"=",
"array",
"(",
")",
")",
"{",
"list",
"(",
"$",
"config",
")",
"=",
"$",
"this",
"->",
"parseOptions",
"(",
"$",
"options",
",",
... | Get a stream info.
@param $domain string, name of play domain
@param $app string, name of app
@param $stream string, name of stream
@param array $options Supported options:
{
config: the optional bce configuration, which will overwrite the
default client configuration that was passed in constructor.
}
@return mixed session detail
@throws BceClientException | [
"Get",
"a",
"stream",
"info",
"."
] | c3164434c8f0fe53b6ffe4479def893465137282 | https://github.com/baidubce/bce-sdk-php/blob/c3164434c8f0fe53b6ffe4479def893465137282/src/BaiduBce/Services/Lss/LssClient.php#L1507-L1531 | train |
baidubce/bce-sdk-php | src/BaiduBce/Services/Lss/LssClient.php | LssClient.createStream | public function createStream($domain, $options = array())
{
list($config,
$app,
$publish,
$scene,
$recording,
$notification,
$thumbnail,
$thumbnails,
$watermarks,
$destinationPushUrl
) = $this->parseOptions(
$options,
'config',
'app',
'publish',
'scene',
'recording',
'notification',
'thumbnail',
'thumbnails',
'watermarks',
'destinationPushUrl');
if (empty($domain)) {
throw new BceClientException("The parameter domain "
. "should NOT be null or empty string");
}
$body = array();
if ($app !== null) {
$body['app'] = $app;
}
if ($publish !== null) {
$body['publish'] = $publish;
}
if ($scene !== null) {
$body['scene'] = $scene;
}
if ($recording !== null) {
$body['recording'] = $recording;
}
if ($notification !== null) {
$body['notification'] = $notification;
}
if ($thumbnail !== null) {
$body['thumbnail'] = $thumbnail;
}
if ($thumbnails !== null) {
$body['thumbnails'] = $thumbnails;
}
if ($watermarks !== null) {
$body['watermarks'] = $watermarks;
}
if ($destinationPushUrl !== null) {
$body['destinationPushUrl'] = $destinationPushUrl;
}
return $this->sendRequest(
HttpMethod::POST,
array(
'config' => $config,
'body' => json_encode($body),
),
"/domain/$domain/stream"
);
} | php | public function createStream($domain, $options = array())
{
list($config,
$app,
$publish,
$scene,
$recording,
$notification,
$thumbnail,
$thumbnails,
$watermarks,
$destinationPushUrl
) = $this->parseOptions(
$options,
'config',
'app',
'publish',
'scene',
'recording',
'notification',
'thumbnail',
'thumbnails',
'watermarks',
'destinationPushUrl');
if (empty($domain)) {
throw new BceClientException("The parameter domain "
. "should NOT be null or empty string");
}
$body = array();
if ($app !== null) {
$body['app'] = $app;
}
if ($publish !== null) {
$body['publish'] = $publish;
}
if ($scene !== null) {
$body['scene'] = $scene;
}
if ($recording !== null) {
$body['recording'] = $recording;
}
if ($notification !== null) {
$body['notification'] = $notification;
}
if ($thumbnail !== null) {
$body['thumbnail'] = $thumbnail;
}
if ($thumbnails !== null) {
$body['thumbnails'] = $thumbnails;
}
if ($watermarks !== null) {
$body['watermarks'] = $watermarks;
}
if ($destinationPushUrl !== null) {
$body['destinationPushUrl'] = $destinationPushUrl;
}
return $this->sendRequest(
HttpMethod::POST,
array(
'config' => $config,
'body' => json_encode($body),
),
"/domain/$domain/stream"
);
} | [
"public",
"function",
"createStream",
"(",
"$",
"domain",
",",
"$",
"options",
"=",
"array",
"(",
")",
")",
"{",
"list",
"(",
"$",
"config",
",",
"$",
"app",
",",
"$",
"publish",
",",
"$",
"scene",
",",
"$",
"recording",
",",
"$",
"notification",
"... | Create a stream.
@param $domain string, name of play domain
@param $stream string, name of stream
@param array $options Supported options:
{
config: the optional bce configuration, which will overwrite the
default client configuration that was passed in constructor.
}
@return mixed session detail
@throws BceClientException | [
"Create",
"a",
"stream",
"."
] | c3164434c8f0fe53b6ffe4479def893465137282 | https://github.com/baidubce/bce-sdk-php/blob/c3164434c8f0fe53b6ffe4479def893465137282/src/BaiduBce/Services/Lss/LssClient.php#L1546-L1614 | train |
baidubce/bce-sdk-php | src/BaiduBce/Services/Lss/LssClient.php | LssClient.listStreams | public function listStreams($domain, $options = array())
{
list($config, $status, $marker, $maxSize) = $this->parseOptions($options, 'config', 'status', 'marker', 'maxSize');
$params = array();
if (empty($domain)) {
throw new BceClientException("The parameter domain "
. "should NOT be null or empty string");
}
if ($status !== null) {
$params['status'] = $status;
}
if ($marker !== null) {
$params['marker'] = $marker;
}
if ($maxSize !== null) {
$params['maxSize'] = $maxSize;
}
return $this->sendRequest(
HttpMethod::GET,
array(
'config' => $config,
'params' => $params,
),
"/domain/$domain/stream"
);
} | php | public function listStreams($domain, $options = array())
{
list($config, $status, $marker, $maxSize) = $this->parseOptions($options, 'config', 'status', 'marker', 'maxSize');
$params = array();
if (empty($domain)) {
throw new BceClientException("The parameter domain "
. "should NOT be null or empty string");
}
if ($status !== null) {
$params['status'] = $status;
}
if ($marker !== null) {
$params['marker'] = $marker;
}
if ($maxSize !== null) {
$params['maxSize'] = $maxSize;
}
return $this->sendRequest(
HttpMethod::GET,
array(
'config' => $config,
'params' => $params,
),
"/domain/$domain/stream"
);
} | [
"public",
"function",
"listStreams",
"(",
"$",
"domain",
",",
"$",
"options",
"=",
"array",
"(",
")",
")",
"{",
"list",
"(",
"$",
"config",
",",
"$",
"status",
",",
"$",
"marker",
",",
"$",
"maxSize",
")",
"=",
"$",
"this",
"->",
"parseOptions",
"(... | List streams.
@param array $options Supported options:
{
config: the optional bce configuration, which will overwrite the
default client configuration that was passed in constructor.
status: stream status, READY / ONGOING / PAUSED
marker: query marker.
maxSize: max number of listed sessions.
}
@return mixed stream list | [
"List",
"streams",
"."
] | c3164434c8f0fe53b6ffe4479def893465137282 | https://github.com/baidubce/bce-sdk-php/blob/c3164434c8f0fe53b6ffe4479def893465137282/src/BaiduBce/Services/Lss/LssClient.php#L1669-L1697 | train |
baidubce/bce-sdk-php | src/BaiduBce/Services/Lss/LssClient.php | LssClient.pauseStream | public function pauseStream($domain, $app, $stream, $options = array())
{
list($config) = $this->parseOptions($options, 'config');
if (empty($domain)) {
throw new BceClientException("The parameter domain "
. "should NOT be null or empty string");
}
if (empty($app)) {
throw new BceClientException("The parameter app "
. "should NOT be null or empty string");
}
if (empty($stream)) {
throw new BceClientException("The parameter stream "
. "should NOT be null or empty string");
}
$params = array(
'pause' => null,
);
return $this->sendRequest(
HttpMethod::PUT,
array(
'config' => $config,
'params' => $params,
),
"/domain/$domain/app/$app/stream/$stream"
);
} | php | public function pauseStream($domain, $app, $stream, $options = array())
{
list($config) = $this->parseOptions($options, 'config');
if (empty($domain)) {
throw new BceClientException("The parameter domain "
. "should NOT be null or empty string");
}
if (empty($app)) {
throw new BceClientException("The parameter app "
. "should NOT be null or empty string");
}
if (empty($stream)) {
throw new BceClientException("The parameter stream "
. "should NOT be null or empty string");
}
$params = array(
'pause' => null,
);
return $this->sendRequest(
HttpMethod::PUT,
array(
'config' => $config,
'params' => $params,
),
"/domain/$domain/app/$app/stream/$stream"
);
} | [
"public",
"function",
"pauseStream",
"(",
"$",
"domain",
",",
"$",
"app",
",",
"$",
"stream",
",",
"$",
"options",
"=",
"array",
"(",
")",
")",
"{",
"list",
"(",
"$",
"config",
")",
"=",
"$",
"this",
"->",
"parseOptions",
"(",
"$",
"options",
",",
... | Pause a stream.
@param $domain string, name of play domain
@param $app string, name of app
@param $stream string, name of stream
@param array $options Supported options:
{
config: the optional bce configuration, which will overwrite the
default client configuration that was passed in constructor.
}
@return mixed
@throws BceClientException | [
"Pause",
"a",
"stream",
"."
] | c3164434c8f0fe53b6ffe4479def893465137282 | https://github.com/baidubce/bce-sdk-php/blob/c3164434c8f0fe53b6ffe4479def893465137282/src/BaiduBce/Services/Lss/LssClient.php#L1713-L1742 | train |
baidubce/bce-sdk-php | src/BaiduBce/Services/Lss/LssClient.php | LssClient.getDomainStatistics | public function getDomainStatistics($domain, $options = array())
{
list($config, $startDate, $endDate, $aggregate) = $this->parseOptions(
$options,
'config',
'startDate',
'endDate',
'aggregate'
);
if (empty($domain)) {
throw new BceClientException("The parameter domain "
. "should NOT be null or empty string");
}
if (empty($startDate)) {
throw new BceClientException("The query parameter startDate "
. "should NOT be null or empty string");
}
if (empty($endDate)) {
throw new BceClientException("The query parameter endDate "
. "should NOT be null or empty string");
}
$params = array(
'startDate' => $startDate,
'endDate' => $endDate,
'aggregate' => $aggregate,
);
return $this->sendRequest(
HttpMethod::GET,
array(
'config' => $config,
'params' => $params,
),
"/statistics/domain/$domain"
);
} | php | public function getDomainStatistics($domain, $options = array())
{
list($config, $startDate, $endDate, $aggregate) = $this->parseOptions(
$options,
'config',
'startDate',
'endDate',
'aggregate'
);
if (empty($domain)) {
throw new BceClientException("The parameter domain "
. "should NOT be null or empty string");
}
if (empty($startDate)) {
throw new BceClientException("The query parameter startDate "
. "should NOT be null or empty string");
}
if (empty($endDate)) {
throw new BceClientException("The query parameter endDate "
. "should NOT be null or empty string");
}
$params = array(
'startDate' => $startDate,
'endDate' => $endDate,
'aggregate' => $aggregate,
);
return $this->sendRequest(
HttpMethod::GET,
array(
'config' => $config,
'params' => $params,
),
"/statistics/domain/$domain"
);
} | [
"public",
"function",
"getDomainStatistics",
"(",
"$",
"domain",
",",
"$",
"options",
"=",
"array",
"(",
")",
")",
"{",
"list",
"(",
"$",
"config",
",",
"$",
"startDate",
",",
"$",
"endDate",
",",
"$",
"aggregate",
")",
"=",
"$",
"this",
"->",
"parse... | Get domain static info.
@param $domain string, name of play domain
@param array $options Supported options:
{
config: the optional bce configuration, which will overwrite the
default client configuration that was passed in constructor.
}
@return mixed
@throws BceClientException | [
"Get",
"domain",
"static",
"info",
"."
] | c3164434c8f0fe53b6ffe4479def893465137282 | https://github.com/baidubce/bce-sdk-php/blob/c3164434c8f0fe53b6ffe4479def893465137282/src/BaiduBce/Services/Lss/LssClient.php#L1801-L1838 | train |
baidubce/bce-sdk-php | src/BaiduBce/Services/Lss/LssClient.php | LssClient.getDomainSummaryStatistics | public function getDomainSummaryStatistics($options = array())
{
list($config, $startTime, $endTime) = $this->parseOptions(
$options,
'config',
'startTime',
'endTime'
);
if (empty($startTime)) {
throw new BceClientException("The query parameter startTime "
. "should NOT be null or empty string");
}
if (empty($endTime)) {
throw new BceClientException("The query parameter endTime "
. "should NOT be null or empty string");
}
$params = array(
'startTime' => $startTime,
'endTime' => $endTime,
);
return $this->sendRequest(
HttpMethod::GET,
array(
'config' => $config,
'params' => $params,
),
"/statistics/domain/summary"
);
} | php | public function getDomainSummaryStatistics($options = array())
{
list($config, $startTime, $endTime) = $this->parseOptions(
$options,
'config',
'startTime',
'endTime'
);
if (empty($startTime)) {
throw new BceClientException("The query parameter startTime "
. "should NOT be null or empty string");
}
if (empty($endTime)) {
throw new BceClientException("The query parameter endTime "
. "should NOT be null or empty string");
}
$params = array(
'startTime' => $startTime,
'endTime' => $endTime,
);
return $this->sendRequest(
HttpMethod::GET,
array(
'config' => $config,
'params' => $params,
),
"/statistics/domain/summary"
);
} | [
"public",
"function",
"getDomainSummaryStatistics",
"(",
"$",
"options",
"=",
"array",
"(",
")",
")",
"{",
"list",
"(",
"$",
"config",
",",
"$",
"startTime",
",",
"$",
"endTime",
")",
"=",
"$",
"this",
"->",
"parseOptions",
"(",
"$",
"options",
",",
"'... | Get domain summary static info.
@param array $options Supported options:
{
config: the optional bce configuration, which will overwrite the
default client configuration that was passed in constructor.
}
@return mixed
@throws BceClientException | [
"Get",
"domain",
"summary",
"static",
"info",
"."
] | c3164434c8f0fe53b6ffe4479def893465137282 | https://github.com/baidubce/bce-sdk-php/blob/c3164434c8f0fe53b6ffe4479def893465137282/src/BaiduBce/Services/Lss/LssClient.php#L1851-L1882 | train |
baidubce/bce-sdk-php | src/BaiduBce/Services/Lss/LssClient.php | LssClient.listDomainStatistics | public function listDomainStatistics($options = array())
{
list($config, $startTime, $endTime, $keywordType, $keyword, $orderBy) = $this->parseOptions(
$options,
'config',
'startTime',
'endTime',
'keywordType',
'keyword',
'orderBy'
);
if (empty($startTime)) {
throw new BceClientException("The query parameter startTime "
. "should NOT be null or empty string");
}
if (empty($endTime)) {
throw new BceClientException("The query parameter endTime "
. "should NOT be null or empty string");
}
$params = array(
'startTime' => $startTime,
'endTime' => $endTime,
'keywordType' => $keywordType,
'keyword' => $keyword,
'orderBy' => $orderBy,
);
return $this->sendRequest(
HttpMethod::GET,
array(
'config' => $config,
'params' => $params,
),
"/statistics/domain/list"
);
} | php | public function listDomainStatistics($options = array())
{
list($config, $startTime, $endTime, $keywordType, $keyword, $orderBy) = $this->parseOptions(
$options,
'config',
'startTime',
'endTime',
'keywordType',
'keyword',
'orderBy'
);
if (empty($startTime)) {
throw new BceClientException("The query parameter startTime "
. "should NOT be null or empty string");
}
if (empty($endTime)) {
throw new BceClientException("The query parameter endTime "
. "should NOT be null or empty string");
}
$params = array(
'startTime' => $startTime,
'endTime' => $endTime,
'keywordType' => $keywordType,
'keyword' => $keyword,
'orderBy' => $orderBy,
);
return $this->sendRequest(
HttpMethod::GET,
array(
'config' => $config,
'params' => $params,
),
"/statistics/domain/list"
);
} | [
"public",
"function",
"listDomainStatistics",
"(",
"$",
"options",
"=",
"array",
"(",
")",
")",
"{",
"list",
"(",
"$",
"config",
",",
"$",
"startTime",
",",
"$",
"endTime",
",",
"$",
"keywordType",
",",
"$",
"keyword",
",",
"$",
"orderBy",
")",
"=",
... | List domain static info.
@param array $options Supported options:
{
config: the optional bce configuration, which will overwrite the
default client configuration that was passed in constructor.
}
@return mixed
@throws BceClientException | [
"List",
"domain",
"static",
"info",
"."
] | c3164434c8f0fe53b6ffe4479def893465137282 | https://github.com/baidubce/bce-sdk-php/blob/c3164434c8f0fe53b6ffe4479def893465137282/src/BaiduBce/Services/Lss/LssClient.php#L1895-L1932 | train |
baidubce/bce-sdk-php | src/BaiduBce/Services/Lss/LssClient.php | LssClient.getStreamStatistics | public function getStreamStatistics($domain, $app, $stream, $options = array())
{
list($config, $startDate, $endDate, $aggregate) = $this->parseOptions(
$options,
'config',
'startDate',
'endDate',
'aggregate'
);
if (empty($domain)) {
throw new BceClientException("The parameter domain "
. "should NOT be null or empty string");
}
if (empty($app)) {
throw new BceClientException("The parameter app "
. "should NOT be null or empty string");
}
if (empty($stream)) {
throw new BceClientException("The parameter stream "
. "should NOT be null or empty string");
}
if (empty($startDate)) {
throw new BceClientException("The query parameter startDate "
. "should NOT be null or empty string");
}
if (empty($endDate)) {
throw new BceClientException("The query parameter endDate "
. "should NOT be null or empty string");
}
$params = array(
'startDate' => $startDate,
'endDate' => $endDate,
'aggregate' => $aggregate,
);
return $this->sendRequest(
HttpMethod::GET,
array(
'config' => $config,
'params' => $params,
),
"/statistics/domain/$domain/app/$app/stream/$stream"
);
} | php | public function getStreamStatistics($domain, $app, $stream, $options = array())
{
list($config, $startDate, $endDate, $aggregate) = $this->parseOptions(
$options,
'config',
'startDate',
'endDate',
'aggregate'
);
if (empty($domain)) {
throw new BceClientException("The parameter domain "
. "should NOT be null or empty string");
}
if (empty($app)) {
throw new BceClientException("The parameter app "
. "should NOT be null or empty string");
}
if (empty($stream)) {
throw new BceClientException("The parameter stream "
. "should NOT be null or empty string");
}
if (empty($startDate)) {
throw new BceClientException("The query parameter startDate "
. "should NOT be null or empty string");
}
if (empty($endDate)) {
throw new BceClientException("The query parameter endDate "
. "should NOT be null or empty string");
}
$params = array(
'startDate' => $startDate,
'endDate' => $endDate,
'aggregate' => $aggregate,
);
return $this->sendRequest(
HttpMethod::GET,
array(
'config' => $config,
'params' => $params,
),
"/statistics/domain/$domain/app/$app/stream/$stream"
);
} | [
"public",
"function",
"getStreamStatistics",
"(",
"$",
"domain",
",",
"$",
"app",
",",
"$",
"stream",
",",
"$",
"options",
"=",
"array",
"(",
")",
")",
"{",
"list",
"(",
"$",
"config",
",",
"$",
"startDate",
",",
"$",
"endDate",
",",
"$",
"aggregate"... | Get stream static info.
@param $domain string, name of play domain
@param $app string, name of app
@param $stream string, name of stream
@param array $options Supported options:
{
config: the optional bce configuration, which will overwrite the
default client configuration that was passed in constructor.
}
@return mixed
@throws BceClientException | [
"Get",
"stream",
"static",
"info",
"."
] | c3164434c8f0fe53b6ffe4479def893465137282 | https://github.com/baidubce/bce-sdk-php/blob/c3164434c8f0fe53b6ffe4479def893465137282/src/BaiduBce/Services/Lss/LssClient.php#L1948-L1994 | train |
baidubce/bce-sdk-php | src/BaiduBce/Services/Lss/LssClient.php | LssClient.listStreamStatistics | public function listStreamStatistics($domain, $options = array())
{
list($config, $app, $startTime, $endTime, $pageNo, $pageSize,
$keywordType, $keyword, $orderBy) = $this->parseOptions(
$options,
'config',
'app',
'startTime',
'endTime',
'pageNo',
'pageSize',
'keywordType',
'keyword',
'orderBy'
);
if (empty($domain)) {
throw new BceClientException("The parameter domain "
. "should NOT be null or empty string");
}
if (empty($startTime)) {
throw new BceClientException("The query parameter startTime "
. "should NOT be null or empty string");
}
if (empty($endTime)) {
throw new BceClientException("The query parameter endTime "
. "should NOT be null or empty string");
}
$params = array(
'app' => $app,
'startTime' => $startTime,
'endTime' => $endTime,
'pageNo' => $pageNo,
'pageSize' => $pageSize,
'keywordType' => $keywordType,
'keyword' => $keyword,
'orderBy' => $orderBy,
);
return $this->sendRequest(
HttpMethod::GET,
array(
'config' => $config,
'params' => $params,
),
"/statistics/domain/$domain/stream"
);
} | php | public function listStreamStatistics($domain, $options = array())
{
list($config, $app, $startTime, $endTime, $pageNo, $pageSize,
$keywordType, $keyword, $orderBy) = $this->parseOptions(
$options,
'config',
'app',
'startTime',
'endTime',
'pageNo',
'pageSize',
'keywordType',
'keyword',
'orderBy'
);
if (empty($domain)) {
throw new BceClientException("The parameter domain "
. "should NOT be null or empty string");
}
if (empty($startTime)) {
throw new BceClientException("The query parameter startTime "
. "should NOT be null or empty string");
}
if (empty($endTime)) {
throw new BceClientException("The query parameter endTime "
. "should NOT be null or empty string");
}
$params = array(
'app' => $app,
'startTime' => $startTime,
'endTime' => $endTime,
'pageNo' => $pageNo,
'pageSize' => $pageSize,
'keywordType' => $keywordType,
'keyword' => $keyword,
'orderBy' => $orderBy,
);
return $this->sendRequest(
HttpMethod::GET,
array(
'config' => $config,
'params' => $params,
),
"/statistics/domain/$domain/stream"
);
} | [
"public",
"function",
"listStreamStatistics",
"(",
"$",
"domain",
",",
"$",
"options",
"=",
"array",
"(",
")",
")",
"{",
"list",
"(",
"$",
"config",
",",
"$",
"app",
",",
"$",
"startTime",
",",
"$",
"endTime",
",",
"$",
"pageNo",
",",
"$",
"pageSize"... | List stream static info.
@param $domain string, name of play domain
@param array $options Supported options:
{
config: the optional bce configuration, which will overwrite the
default client configuration that was passed in constructor.
}
@return mixed
@throws BceClientException | [
"List",
"stream",
"static",
"info",
"."
] | c3164434c8f0fe53b6ffe4479def893465137282 | https://github.com/baidubce/bce-sdk-php/blob/c3164434c8f0fe53b6ffe4479def893465137282/src/BaiduBce/Services/Lss/LssClient.php#L2008-L2056 | train |
baidubce/bce-sdk-php | src/BaiduBce/Services/Lss/LssClient.php | LssClient.updateWatermarksOfStream | public function updateWatermarksOfStream($domain, $app, $stream, $options = array())
{
list($config, $watermarks) = $this->parseOptions($options, 'config', 'watermarks');
if (empty($domain)) {
throw new BceClientException("The parameter domain "
. "should NOT be null or empty string");
}
if (empty($app)) {
throw new BceClientException("The parameter app "
. "should NOT be null or empty string");
}
if (empty($stream)) {
throw new BceClientException("The parameter stream "
. "should NOT be null or empty string");
}
$body = array();
if (count($watermarks) > 0) {
$body['watermarks'] = $watermarks;
}
$params = array(
'watermark' => null,
);
return $this->sendRequest(
HttpMethod::POST,
array(
'config' => $config,
'params' => $params,
'body' => json_encode($body),
),
"/domain/$domain/app/$app/stream/$stream"
);
} | php | public function updateWatermarksOfStream($domain, $app, $stream, $options = array())
{
list($config, $watermarks) = $this->parseOptions($options, 'config', 'watermarks');
if (empty($domain)) {
throw new BceClientException("The parameter domain "
. "should NOT be null or empty string");
}
if (empty($app)) {
throw new BceClientException("The parameter app "
. "should NOT be null or empty string");
}
if (empty($stream)) {
throw new BceClientException("The parameter stream "
. "should NOT be null or empty string");
}
$body = array();
if (count($watermarks) > 0) {
$body['watermarks'] = $watermarks;
}
$params = array(
'watermark' => null,
);
return $this->sendRequest(
HttpMethod::POST,
array(
'config' => $config,
'params' => $params,
'body' => json_encode($body),
),
"/domain/$domain/app/$app/stream/$stream"
);
} | [
"public",
"function",
"updateWatermarksOfStream",
"(",
"$",
"domain",
",",
"$",
"app",
",",
"$",
"stream",
",",
"$",
"options",
"=",
"array",
"(",
")",
")",
"{",
"list",
"(",
"$",
"config",
",",
"$",
"watermarks",
")",
"=",
"$",
"this",
"->",
"parseO... | Update watermark of the stream.
@param $domain string, name of play domain
@param $app string, name of app
@param $stream string, name of stream
@param array $options Supported options:
{
config: the optional bce configuration, which will overwrite the
default client configuration that was passed in constructor.
}
@return mixed
@throws BceClientException | [
"Update",
"watermark",
"of",
"the",
"stream",
"."
] | c3164434c8f0fe53b6ffe4479def893465137282 | https://github.com/baidubce/bce-sdk-php/blob/c3164434c8f0fe53b6ffe4479def893465137282/src/BaiduBce/Services/Lss/LssClient.php#L2394-L2430 | train |
baidubce/bce-sdk-php | src/BaiduBce/Services/Lss/LssClient.php | LssClient.getRealtimeStreamSourceInfo | public function getRealtimeStreamSourceInfo($domain, $app, $stream, $options = array())
{
list($config) = $this->parseOptions($options, 'config');
if (empty($domain)) {
throw new BceClientException("The parameter domain "
. "should NOT be null or empty string");
}
if (empty($app)) {
throw new BceClientException("The parameter app "
. "should NOT be null or empty string");
}
if (empty($stream)) {
throw new BceClientException("The parameter stream "
. "should NOT be null or empty string");
}
$params = array(
'sourceInfo' => null,
);
return $this->sendRequest(
HttpMethod::GET,
array(
'config' => $config,
'params' => $params,
),
"/domain/$domain/app/$app/stream/$stream"
);
} | php | public function getRealtimeStreamSourceInfo($domain, $app, $stream, $options = array())
{
list($config) = $this->parseOptions($options, 'config');
if (empty($domain)) {
throw new BceClientException("The parameter domain "
. "should NOT be null or empty string");
}
if (empty($app)) {
throw new BceClientException("The parameter app "
. "should NOT be null or empty string");
}
if (empty($stream)) {
throw new BceClientException("The parameter stream "
. "should NOT be null or empty string");
}
$params = array(
'sourceInfo' => null,
);
return $this->sendRequest(
HttpMethod::GET,
array(
'config' => $config,
'params' => $params,
),
"/domain/$domain/app/$app/stream/$stream"
);
} | [
"public",
"function",
"getRealtimeStreamSourceInfo",
"(",
"$",
"domain",
",",
"$",
"app",
",",
"$",
"stream",
",",
"$",
"options",
"=",
"array",
"(",
")",
")",
"{",
"list",
"(",
"$",
"config",
")",
"=",
"$",
"this",
"->",
"parseOptions",
"(",
"$",
"o... | Get realtime live source info of the stream.
@param $domain string, name of play domain
@param $app string, name of app
@param $stream string, name of stream
@param array $options Supported options:
{
config: the optional bce configuration, which will overwrite the
default client configuration that was passed in constructor.
}
@return mixed
@throws BceClientException | [
"Get",
"realtime",
"live",
"source",
"info",
"of",
"the",
"stream",
"."
] | c3164434c8f0fe53b6ffe4479def893465137282 | https://github.com/baidubce/bce-sdk-php/blob/c3164434c8f0fe53b6ffe4479def893465137282/src/BaiduBce/Services/Lss/LssClient.php#L2481-L2510 | train |
baidubce/bce-sdk-php | src/BaiduBce/BceBaseClient.php | BceBaseClient.computeEndpoint | private function computeEndpoint()
{
$protocol = $this->config[BceClientConfigOptions::PROTOCOL];
if ($this->regionSupported) {
return sprintf(
'%s://%s.%s.%s',
$protocol,
$this->serviceId,
$this->config[BceClientConfigOptions::REGION],
Bce::DEFAULT_SERVICE_DOMAIN
);
} else {
return sprintf(
'%s://%s.%s',
$protocol,
$this->serviceId,
Bce::DEFAULT_SERVICE_DOMAIN
);
}
} | php | private function computeEndpoint()
{
$protocol = $this->config[BceClientConfigOptions::PROTOCOL];
if ($this->regionSupported) {
return sprintf(
'%s://%s.%s.%s',
$protocol,
$this->serviceId,
$this->config[BceClientConfigOptions::REGION],
Bce::DEFAULT_SERVICE_DOMAIN
);
} else {
return sprintf(
'%s://%s.%s',
$protocol,
$this->serviceId,
Bce::DEFAULT_SERVICE_DOMAIN
);
}
} | [
"private",
"function",
"computeEndpoint",
"(",
")",
"{",
"$",
"protocol",
"=",
"$",
"this",
"->",
"config",
"[",
"BceClientConfigOptions",
"::",
"PROTOCOL",
"]",
";",
"if",
"(",
"$",
"this",
"->",
"regionSupported",
")",
"{",
"return",
"sprintf",
"(",
"'%s... | compute endpoint based on the configuration and service id
@return string The endpoint | [
"compute",
"endpoint",
"based",
"on",
"the",
"configuration",
"and",
"service",
"id"
] | c3164434c8f0fe53b6ffe4479def893465137282 | https://github.com/baidubce/bce-sdk-php/blob/c3164434c8f0fe53b6ffe4479def893465137282/src/BaiduBce/BceBaseClient.php#L161-L180 | train |
baidubce/bce-sdk-php | src/BaiduBce/Util/MimeTypes.php | MimeTypes.guessMimeType | static function guessMimeType($fileName)
{
self::$map = include(__DIR__ . "/mime.types.php");
$ext = pathinfo($fileName, PATHINFO_EXTENSION);
return isset(self::$map[$ext]) ? self::$map[$ext] : 'application/octet-stream';
} | php | static function guessMimeType($fileName)
{
self::$map = include(__DIR__ . "/mime.types.php");
$ext = pathinfo($fileName, PATHINFO_EXTENSION);
return isset(self::$map[$ext]) ? self::$map[$ext] : 'application/octet-stream';
} | [
"static",
"function",
"guessMimeType",
"(",
"$",
"fileName",
")",
"{",
"self",
"::",
"$",
"map",
"=",
"include",
"(",
"__DIR__",
".",
"\"/mime.types.php\"",
")",
";",
"$",
"ext",
"=",
"pathinfo",
"(",
"$",
"fileName",
",",
"PATHINFO_EXTENSION",
")",
";",
... | Guess mime-type from file name extension. Return default mime-type if guess failed.
@param string $fileName
@return string | [
"Guess",
"mime",
"-",
"type",
"from",
"file",
"name",
"extension",
".",
"Return",
"default",
"mime",
"-",
"type",
"if",
"guess",
"failed",
"."
] | c3164434c8f0fe53b6ffe4479def893465137282 | https://github.com/baidubce/bce-sdk-php/blob/c3164434c8f0fe53b6ffe4479def893465137282/src/BaiduBce/Util/MimeTypes.php#L30-L35 | train |
baidubce/bce-sdk-php | src/BaiduBce/Log/MonoLogFactory.php | MonoLogFactory.getLogger | public function getLogger($name)
{
$logger = new Logger($name);
if ($this->handlers !== null) {
foreach ($this->handlers as $handler) {
$logger->pushHandler($handler);
}
}
return $logger;
} | php | public function getLogger($name)
{
$logger = new Logger($name);
if ($this->handlers !== null) {
foreach ($this->handlers as $handler) {
$logger->pushHandler($handler);
}
}
return $logger;
} | [
"public",
"function",
"getLogger",
"(",
"$",
"name",
")",
"{",
"$",
"logger",
"=",
"new",
"Logger",
"(",
"$",
"name",
")",
";",
"if",
"(",
"$",
"this",
"->",
"handlers",
"!==",
"null",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"handlers",
"as",
... | Returns \Monolog\Logger.
@param string $name the name of logger
@return \Monolog\Logger a monolog logger instance | [
"Returns",
"\\",
"Monolog",
"\\",
"Logger",
"."
] | c3164434c8f0fe53b6ffe4479def893465137282 | https://github.com/baidubce/bce-sdk-php/blob/c3164434c8f0fe53b6ffe4479def893465137282/src/BaiduBce/Log/MonoLogFactory.php#L50-L59 | train |
baidubce/bce-sdk-php | src/BaiduBce/Util/HttpUtils.php | HttpUtils.appendUri | public static function appendUri()
{
$path = array();
foreach (func_get_args() as $arg) {
if ($arg !== null) {
$path[] = $arg;
}
}
if (count($path) > 1) {
$last = count($path) - 1;
$path[0] = rtrim($path[0], '/');
$path[$last] = ltrim($path[$last], '/');
for ($i = 1; $i < $last; ++$i) {
$path[$i] = trim($path[$i], '/');
}
}
return implode("/", $path);
} | php | public static function appendUri()
{
$path = array();
foreach (func_get_args() as $arg) {
if ($arg !== null) {
$path[] = $arg;
}
}
if (count($path) > 1) {
$last = count($path) - 1;
$path[0] = rtrim($path[0], '/');
$path[$last] = ltrim($path[$last], '/');
for ($i = 1; $i < $last; ++$i) {
$path[$i] = trim($path[$i], '/');
}
}
return implode("/", $path);
} | [
"public",
"static",
"function",
"appendUri",
"(",
")",
"{",
"$",
"path",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"func_get_args",
"(",
")",
"as",
"$",
"arg",
")",
"{",
"if",
"(",
"$",
"arg",
"!==",
"null",
")",
"{",
"$",
"path",
"[",
"]",
... | Append the given path to the given baseUri.
<p>
This method will encode the given path but not the given baseUri. | [
"Append",
"the",
"given",
"path",
"to",
"the",
"given",
"baseUri",
"."
] | c3164434c8f0fe53b6ffe4479def893465137282 | https://github.com/baidubce/bce-sdk-php/blob/c3164434c8f0fe53b6ffe4479def893465137282/src/BaiduBce/Util/HttpUtils.php#L190-L208 | train |
baidubce/bce-sdk-php | src/BaiduBce/Http/GuzzleLogAdapter.php | GuzzleLogAdapter.log | public function log($message, $priority = LOG_INFO, $extras = array())
{
// All guzzle logs should be DEBUG, regardless of its own priority.
if (LogFactory::isDebugEnabled()) {
// To avoid memory exhausted, truncate request or response longer than 1024 bytes.
if(strlen($extras['request']) > 1024){
$extras['request'] = substr($request, 0, 1024);
}
if(strlen($extras['response']) > 1024){
$extras['response'] = substr($response, 0, 1024);
}
$this->logger->log(LogLevel::DEBUG, $message, $extras);
}
} | php | public function log($message, $priority = LOG_INFO, $extras = array())
{
// All guzzle logs should be DEBUG, regardless of its own priority.
if (LogFactory::isDebugEnabled()) {
// To avoid memory exhausted, truncate request or response longer than 1024 bytes.
if(strlen($extras['request']) > 1024){
$extras['request'] = substr($request, 0, 1024);
}
if(strlen($extras['response']) > 1024){
$extras['response'] = substr($response, 0, 1024);
}
$this->logger->log(LogLevel::DEBUG, $message, $extras);
}
} | [
"public",
"function",
"log",
"(",
"$",
"message",
",",
"$",
"priority",
"=",
"LOG_INFO",
",",
"$",
"extras",
"=",
"array",
"(",
")",
")",
"{",
"// All guzzle logs should be DEBUG, regardless of its own priority.",
"if",
"(",
"LogFactory",
"::",
"isDebugEnabled",
"... | Logs the message.
@param string $message the log message
@param int $priority the log level
@param array $extras extra arguments | [
"Logs",
"the",
"message",
"."
] | c3164434c8f0fe53b6ffe4479def893465137282 | https://github.com/baidubce/bce-sdk-php/blob/c3164434c8f0fe53b6ffe4479def893465137282/src/BaiduBce/Http/GuzzleLogAdapter.php#L46-L59 | train |
networking/init-cms-bundle | src/EventListener/AdminTrackerListener.php | AdminTrackerListener.updateTrackedInfo | protected function updateTrackedInfo($session, $sessionKey, $trackInfoArray, $limit = 5)
{
// save the url, controller and action in the session
$value = json_decode($session->get($sessionKey), true);
if (is_null($value)) {
$value = [];
}
// add new value as first value (to the top of the stack)
array_unshift(
$value,
$trackInfoArray
);
// remove last value, if array has more than limit items
if ($limit > 0 and count($value) > $limit) {
array_pop($value);
}
// set the session value
$session->set($sessionKey, json_encode($value));
} | php | protected function updateTrackedInfo($session, $sessionKey, $trackInfoArray, $limit = 5)
{
// save the url, controller and action in the session
$value = json_decode($session->get($sessionKey), true);
if (is_null($value)) {
$value = [];
}
// add new value as first value (to the top of the stack)
array_unshift(
$value,
$trackInfoArray
);
// remove last value, if array has more than limit items
if ($limit > 0 and count($value) > $limit) {
array_pop($value);
}
// set the session value
$session->set($sessionKey, json_encode($value));
} | [
"protected",
"function",
"updateTrackedInfo",
"(",
"$",
"session",
",",
"$",
"sessionKey",
",",
"$",
"trackInfoArray",
",",
"$",
"limit",
"=",
"5",
")",
"{",
"// save the url, controller and action in the session",
"$",
"value",
"=",
"json_decode",
"(",
"$",
"sess... | update tracker info in session.
@param $session
@param string $sessionKey
@param array $trackInfoArray
@param int $limit | [
"update",
"tracker",
"info",
"in",
"session",
"."
] | 9c6e0f09de216e19795caac5840c197f46fde03d | https://github.com/networking/init-cms-bundle/blob/9c6e0f09de216e19795caac5840c197f46fde03d/src/EventListener/AdminTrackerListener.php#L114-L134 | train |
networking/init-cms-bundle | src/Admin/Model/PageAdmin.php | PageAdmin.getPageTemplates | protected function getPageTemplates()
{
$choices = [];
$templates = $this->getContainer()->getParameter('networking_init_cms.page.templates');
foreach ($templates as $key => $template) {
$choices[$template['name']] = $key;
}
return $choices;
} | php | protected function getPageTemplates()
{
$choices = [];
$templates = $this->getContainer()->getParameter('networking_init_cms.page.templates');
foreach ($templates as $key => $template) {
$choices[$template['name']] = $key;
}
return $choices;
} | [
"protected",
"function",
"getPageTemplates",
"(",
")",
"{",
"$",
"choices",
"=",
"[",
"]",
";",
"$",
"templates",
"=",
"$",
"this",
"->",
"getContainer",
"(",
")",
"->",
"getParameter",
"(",
"'networking_init_cms.page.templates'",
")",
";",
"foreach",
"(",
"... | Get the page templates from the configuration and create an array to use in the
choice field in the admin form.
@return array | [
"Get",
"the",
"page",
"templates",
"from",
"the",
"configuration",
"and",
"create",
"an",
"array",
"to",
"use",
"in",
"the",
"choice",
"field",
"in",
"the",
"admin",
"form",
"."
] | 9c6e0f09de216e19795caac5840c197f46fde03d | https://github.com/networking/init-cms-bundle/blob/9c6e0f09de216e19795caac5840c197f46fde03d/src/Admin/Model/PageAdmin.php#L649-L659 | train |
networking/init-cms-bundle | src/Admin/Model/PageAdmin.php | PageAdmin.getDefaultTemplate | protected function getDefaultTemplate()
{
if ($this->getSubject()->getId()) {
return $this->getSubject()->getTemplateName();
}
$templates = $this->getContainer()->getParameter('networking_init_cms.page.templates');
reset($templates);
$defaultTemplate = key($templates);
return $defaultTemplate;
} | php | protected function getDefaultTemplate()
{
if ($this->getSubject()->getId()) {
return $this->getSubject()->getTemplateName();
}
$templates = $this->getContainer()->getParameter('networking_init_cms.page.templates');
reset($templates);
$defaultTemplate = key($templates);
return $defaultTemplate;
} | [
"protected",
"function",
"getDefaultTemplate",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"getSubject",
"(",
")",
"->",
"getId",
"(",
")",
")",
"{",
"return",
"$",
"this",
"->",
"getSubject",
"(",
")",
"->",
"getTemplateName",
"(",
")",
";",
"}",
"... | If there is an object get the object template variable, else get first in template array.
@return string | [
"If",
"there",
"is",
"an",
"object",
"get",
"the",
"object",
"template",
"variable",
"else",
"get",
"first",
"in",
"template",
"array",
"."
] | 9c6e0f09de216e19795caac5840c197f46fde03d | https://github.com/networking/init-cms-bundle/blob/9c6e0f09de216e19795caac5840c197f46fde03d/src/Admin/Model/PageAdmin.php#L666-L676 | train |
networking/init-cms-bundle | src/Admin/Model/PageAdmin.php | PageAdmin.getPageTemplateIcons | protected function getPageTemplateIcons()
{
$icons = [];
$templates = $this->getContainer()->getParameter('networking_init_cms.page.templates');
foreach ($templates as $key => $template) {
$icons[$key] = isset($template['icon']) ? $template['icon'] : '';
}
return $icons;
} | php | protected function getPageTemplateIcons()
{
$icons = [];
$templates = $this->getContainer()->getParameter('networking_init_cms.page.templates');
foreach ($templates as $key => $template) {
$icons[$key] = isset($template['icon']) ? $template['icon'] : '';
}
return $icons;
} | [
"protected",
"function",
"getPageTemplateIcons",
"(",
")",
"{",
"$",
"icons",
"=",
"[",
"]",
";",
"$",
"templates",
"=",
"$",
"this",
"->",
"getContainer",
"(",
")",
"->",
"getParameter",
"(",
"'networking_init_cms.page.templates'",
")",
";",
"foreach",
"(",
... | Get the icons which represent the templates.
@return array | [
"Get",
"the",
"icons",
"which",
"represent",
"the",
"templates",
"."
] | 9c6e0f09de216e19795caac5840c197f46fde03d | https://github.com/networking/init-cms-bundle/blob/9c6e0f09de216e19795caac5840c197f46fde03d/src/Admin/Model/PageAdmin.php#L683-L693 | train |
networking/init-cms-bundle | src/Controller/PageAdminController.php | PageAdminController.translateAction | public function translateAction(Request $request, $id, $locale)
{
/** @var PageInterface $page */
$page = $this->admin->getObject($id);
if (!$page) {
throw new NotFoundHttpException(sprintf('unable to find the object with id : %s', $id));
}
$language = \Locale::getDisplayLanguage($locale);
if ($request->getMethod() == 'POST') {
$pageHelper = $this->container->get('networking_init_cms.helper.page_helper');
try {
$pageCopy = $pageHelper->makeTranslationCopy($page, $locale);
$this->admin->createObjectSecurity($pageCopy);
$status = 'success';
$message = $this->translate(
'message.translation_saved',
['%language%' => $language]
);
$result = 'ok';
$html = $this->renderView(
'@NetworkingInitCms/PageAdmin/page_translation_settings.html.twig',
['object' => $page, 'admin' => $this->admin]
);
} catch (\Exception $e) {
$status = 'error';
$message = $message = $this->translate(
'message.translation_not_saved',
['%language%' => $language, '%url%' => $page->getFullPath()]
);
$result = 'error';
$html = '';
}
if ($this->isXmlHttpRequest()) {
return $this->renderJson(
[
'result' => $result,
'status' => $status,
'html' => $html,
'message' => $message,
]
);
}
$this->get('session')->getFlashBag()->add(
'sonata_flash_'.$status,
$message
);
return $this->redirect($this->admin->generateUrl('edit', ['id' => $id]));
}
return $this->render(
'@NetworkingInitCms/PageAdmin/page_translation_copy.html.twig',
[
'action' => 'copy',
'page' => $page,
'id' => $id,
'locale' => $locale,
'language' => $language,
'admin' => $this->admin,
]
);
} | php | public function translateAction(Request $request, $id, $locale)
{
/** @var PageInterface $page */
$page = $this->admin->getObject($id);
if (!$page) {
throw new NotFoundHttpException(sprintf('unable to find the object with id : %s', $id));
}
$language = \Locale::getDisplayLanguage($locale);
if ($request->getMethod() == 'POST') {
$pageHelper = $this->container->get('networking_init_cms.helper.page_helper');
try {
$pageCopy = $pageHelper->makeTranslationCopy($page, $locale);
$this->admin->createObjectSecurity($pageCopy);
$status = 'success';
$message = $this->translate(
'message.translation_saved',
['%language%' => $language]
);
$result = 'ok';
$html = $this->renderView(
'@NetworkingInitCms/PageAdmin/page_translation_settings.html.twig',
['object' => $page, 'admin' => $this->admin]
);
} catch (\Exception $e) {
$status = 'error';
$message = $message = $this->translate(
'message.translation_not_saved',
['%language%' => $language, '%url%' => $page->getFullPath()]
);
$result = 'error';
$html = '';
}
if ($this->isXmlHttpRequest()) {
return $this->renderJson(
[
'result' => $result,
'status' => $status,
'html' => $html,
'message' => $message,
]
);
}
$this->get('session')->getFlashBag()->add(
'sonata_flash_'.$status,
$message
);
return $this->redirect($this->admin->generateUrl('edit', ['id' => $id]));
}
return $this->render(
'@NetworkingInitCms/PageAdmin/page_translation_copy.html.twig',
[
'action' => 'copy',
'page' => $page,
'id' => $id,
'locale' => $locale,
'language' => $language,
'admin' => $this->admin,
]
);
} | [
"public",
"function",
"translateAction",
"(",
"Request",
"$",
"request",
",",
"$",
"id",
",",
"$",
"locale",
")",
"{",
"/** @var PageInterface $page */",
"$",
"page",
"=",
"$",
"this",
"->",
"admin",
"->",
"getObject",
"(",
"$",
"id",
")",
";",
"if",
"("... | Create a copy of a page in the given local and connect the pages.
@param Request $request
@param $id
@param $locale
@return RedirectResponse|Response
@throws NotFoundHttpException | [
"Create",
"a",
"copy",
"of",
"a",
"page",
"in",
"the",
"given",
"local",
"and",
"connect",
"the",
"pages",
"."
] | 9c6e0f09de216e19795caac5840c197f46fde03d | https://github.com/networking/init-cms-bundle/blob/9c6e0f09de216e19795caac5840c197f46fde03d/src/Controller/PageAdminController.php#L45-L111 | train |
networking/init-cms-bundle | src/Controller/PageAdminController.php | PageAdminController.linkAction | public function linkAction(Request $request, $id, $locale)
{
/** @var PageInterface $page */
$page = $this->admin->getObject($id);
if (!$page) {
throw new NotFoundHttpException(sprintf('unable to find the Page with id : %s', $id));
}
if ($request->getMethod() == 'POST') {
$linkPageId = $request->get('page');
if (!$linkPageId) {
$this->get('session')->getFlashBag()->add('sonata_flash_error', 'flash_link_error');
} else {
/** @var PageInterface $linkPage */
$linkPage = $this->admin->getObject($linkPageId);
$page->addTranslation($linkPage);
$this->admin->update($page);
if ($this->isXmlHttpRequest()) {
$html = $this->renderView(
'@NetworkingInitCms/PageAdmin/page_translation_settings.html.twig',
['object' => $page, 'admin' => $this->admin]
);
return $this->renderJson(
[
'result' => 'ok',
'html' => $html,
]
);
}
$this->get('session')->getFlashBag()->add('sonata_flash_success', 'flash_link_success');
return new RedirectResponse($this->admin->generateUrl('edit', ['id' => $page->getId()]));
}
}
$pages = $this->admin->getModelManager()->findBy($this->admin->getClass(), ['locale' => $locale]);
if (count($pages)) {
$pages = new ArrayCollection($pages);
$originalLocale = $page->getLocale();
$pages = $pages->filter(
function (PageInterface $linkPage) use ($originalLocale) {
return !in_array($originalLocale, $linkPage->getTranslatedLocales());
}
);
}
return $this->renderWithExtraParams(
'@NetworkingInitCms/PageAdmin/page_translation_link_list.html.twig',
[
'page' => $page,
'pages' => $pages,
'locale' => $locale,
'original_language' => \Locale::getDisplayLanguage($page->getLocale()),
'language' => \Locale::getDisplayLanguage($locale),
'admin' => $this->admin,
]
);
} | php | public function linkAction(Request $request, $id, $locale)
{
/** @var PageInterface $page */
$page = $this->admin->getObject($id);
if (!$page) {
throw new NotFoundHttpException(sprintf('unable to find the Page with id : %s', $id));
}
if ($request->getMethod() == 'POST') {
$linkPageId = $request->get('page');
if (!$linkPageId) {
$this->get('session')->getFlashBag()->add('sonata_flash_error', 'flash_link_error');
} else {
/** @var PageInterface $linkPage */
$linkPage = $this->admin->getObject($linkPageId);
$page->addTranslation($linkPage);
$this->admin->update($page);
if ($this->isXmlHttpRequest()) {
$html = $this->renderView(
'@NetworkingInitCms/PageAdmin/page_translation_settings.html.twig',
['object' => $page, 'admin' => $this->admin]
);
return $this->renderJson(
[
'result' => 'ok',
'html' => $html,
]
);
}
$this->get('session')->getFlashBag()->add('sonata_flash_success', 'flash_link_success');
return new RedirectResponse($this->admin->generateUrl('edit', ['id' => $page->getId()]));
}
}
$pages = $this->admin->getModelManager()->findBy($this->admin->getClass(), ['locale' => $locale]);
if (count($pages)) {
$pages = new ArrayCollection($pages);
$originalLocale = $page->getLocale();
$pages = $pages->filter(
function (PageInterface $linkPage) use ($originalLocale) {
return !in_array($originalLocale, $linkPage->getTranslatedLocales());
}
);
}
return $this->renderWithExtraParams(
'@NetworkingInitCms/PageAdmin/page_translation_link_list.html.twig',
[
'page' => $page,
'pages' => $pages,
'locale' => $locale,
'original_language' => \Locale::getDisplayLanguage($page->getLocale()),
'language' => \Locale::getDisplayLanguage($locale),
'admin' => $this->admin,
]
);
} | [
"public",
"function",
"linkAction",
"(",
"Request",
"$",
"request",
",",
"$",
"id",
",",
"$",
"locale",
")",
"{",
"/** @var PageInterface $page */",
"$",
"page",
"=",
"$",
"this",
"->",
"admin",
"->",
"getObject",
"(",
"$",
"id",
")",
";",
"if",
"(",
"... | Link pages as translations of each other.
@param Request $request
@param $id
@param $locale
@throws NotFoundHttpException
@return RedirectResponse|Response | [
"Link",
"pages",
"as",
"translations",
"of",
"each",
"other",
"."
] | 9c6e0f09de216e19795caac5840c197f46fde03d | https://github.com/networking/init-cms-bundle/blob/9c6e0f09de216e19795caac5840c197f46fde03d/src/Controller/PageAdminController.php#L203-L267 | train |
networking/init-cms-bundle | src/Controller/PageAdminController.php | PageAdminController.getAjaxEditResponse | protected function getAjaxEditResponse(Form $form, PageInterface $page)
{
$view = $form->createView();
// set the theme for the current Admin Form
$this->setFormTheme($view, $this->admin->getFormTheme());
$pageSettingsHtml = $this->renderView(
'@NetworkingInitCms/PageAdmin/page_settings_fields.html.twig',
[
'action' => 'edit',
'form' => $view,
'object' => $page,
'admin' => $this->admin,
'admin_pool' => $this->get('sonata.admin.pool'),
]
);
$pageStatusSettingsHtml = $this->renderView(
'@NetworkingInitCms/PageAdmin/page_status_settings.html.twig',
[
'action' => 'edit',
'form' => $view,
'object' => $page,
'admin' => $this->admin,
'admin_pool' => $this->get('sonata.admin.pool'),
]
);
return $this->renderJson(
[
'result' => 'ok',
'objectId' => $page->getId(),
'title' => $page->__toString(),
'messageStatus' => 'success',
'message' => $this->translate('info.page_settings_updated'),
'pageStatus' => $this->translate($page->getStatus()),
'pageStatusSettings' => $pageStatusSettingsHtml,
'pageSettings' => $pageSettingsHtml,
]
);
} | php | protected function getAjaxEditResponse(Form $form, PageInterface $page)
{
$view = $form->createView();
// set the theme for the current Admin Form
$this->setFormTheme($view, $this->admin->getFormTheme());
$pageSettingsHtml = $this->renderView(
'@NetworkingInitCms/PageAdmin/page_settings_fields.html.twig',
[
'action' => 'edit',
'form' => $view,
'object' => $page,
'admin' => $this->admin,
'admin_pool' => $this->get('sonata.admin.pool'),
]
);
$pageStatusSettingsHtml = $this->renderView(
'@NetworkingInitCms/PageAdmin/page_status_settings.html.twig',
[
'action' => 'edit',
'form' => $view,
'object' => $page,
'admin' => $this->admin,
'admin_pool' => $this->get('sonata.admin.pool'),
]
);
return $this->renderJson(
[
'result' => 'ok',
'objectId' => $page->getId(),
'title' => $page->__toString(),
'messageStatus' => 'success',
'message' => $this->translate('info.page_settings_updated'),
'pageStatus' => $this->translate($page->getStatus()),
'pageStatusSettings' => $pageStatusSettingsHtml,
'pageSettings' => $pageSettingsHtml,
]
);
} | [
"protected",
"function",
"getAjaxEditResponse",
"(",
"Form",
"$",
"form",
",",
"PageInterface",
"$",
"page",
")",
"{",
"$",
"view",
"=",
"$",
"form",
"->",
"createView",
"(",
")",
";",
"// set the theme for the current Admin Form",
"$",
"this",
"->",
"setFormThe... | Return the json response for the ajax edit action.
@param Form $form
@param PageInterface $page
@return Response
@throws \Twig_Error_Runtime | [
"Return",
"the",
"json",
"response",
"for",
"the",
"ajax",
"edit",
"action",
"."
] | 9c6e0f09de216e19795caac5840c197f46fde03d | https://github.com/networking/init-cms-bundle/blob/9c6e0f09de216e19795caac5840c197f46fde03d/src/Controller/PageAdminController.php#L693-L734 | train |
networking/init-cms-bundle | src/Controller/PageAdminController.php | PageAdminController.makeSnapshot | protected function makeSnapshot(PageInterface $page)
{
if (!$this->admin->isGranted('PUBLISH', $page)) {
return;
}
/** @var $pageHelper \Networking\InitCmsBundle\Helper\PageHelper */
$pageHelper = $this->get('networking_init_cms.helper.page_helper');
$pageHelper->makePageSnapshot($page);
} | php | protected function makeSnapshot(PageInterface $page)
{
if (!$this->admin->isGranted('PUBLISH', $page)) {
return;
}
/** @var $pageHelper \Networking\InitCmsBundle\Helper\PageHelper */
$pageHelper = $this->get('networking_init_cms.helper.page_helper');
$pageHelper->makePageSnapshot($page);
} | [
"protected",
"function",
"makeSnapshot",
"(",
"PageInterface",
"$",
"page",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"admin",
"->",
"isGranted",
"(",
"'PUBLISH'",
",",
"$",
"page",
")",
")",
"{",
"return",
";",
"}",
"/** @var $pageHelper \\Networking\\In... | Create a snapshot of a published page.
@param PageInterface $page | [
"Create",
"a",
"snapshot",
"of",
"a",
"published",
"page",
"."
] | 9c6e0f09de216e19795caac5840c197f46fde03d | https://github.com/networking/init-cms-bundle/blob/9c6e0f09de216e19795caac5840c197f46fde03d/src/Controller/PageAdminController.php#L967-L977 | train |
networking/init-cms-bundle | src/Controller/PageAdminController.php | PageAdminController.getPathAction | public function getPathAction(Request $request)
{
$id = $request->get('page_id');
$getPath = $request->get('path');
$object = $this->admin->getObject($id);
if ($id && $object) {
$path = $object->getFullPath();
} else {
$path = '/';
}
$getPath = Urlizer::urlize($getPath);
return $this->renderJson(['path' => $path.$getPath]);
} | php | public function getPathAction(Request $request)
{
$id = $request->get('page_id');
$getPath = $request->get('path');
$object = $this->admin->getObject($id);
if ($id && $object) {
$path = $object->getFullPath();
} else {
$path = '/';
}
$getPath = Urlizer::urlize($getPath);
return $this->renderJson(['path' => $path.$getPath]);
} | [
"public",
"function",
"getPathAction",
"(",
"Request",
"$",
"request",
")",
"{",
"$",
"id",
"=",
"$",
"request",
"->",
"get",
"(",
"'page_id'",
")",
";",
"$",
"getPath",
"=",
"$",
"request",
"->",
"get",
"(",
"'path'",
")",
";",
"$",
"object",
"=",
... | Return a json array with the calculated path for a page object.
@param Request $request
@internal param string $path
@return Response | [
"Return",
"a",
"json",
"array",
"with",
"the",
"calculated",
"path",
"for",
"a",
"page",
"object",
"."
] | 9c6e0f09de216e19795caac5840c197f46fde03d | https://github.com/networking/init-cms-bundle/blob/9c6e0f09de216e19795caac5840c197f46fde03d/src/Controller/PageAdminController.php#L988-L1004 | train |
networking/init-cms-bundle | src/Controller/XmlController.php | XmlController.sitemapAction | public function sitemapAction(Request $request, $locale)
{
$params = [];
$params['domain'] = $this->getDomainName($request);
$params['languages'] = $this->container->getParameter('networking_init_cms.page.languages');
if ($locale != '' or count($params['languages']) == 1) {
//sitemap ausgeben
if ($locale == '') { //use locale as default value
$locale = $params['languages']['locale'];
}
$page_filter = ['visibility' => 'public', 'status' => 'status_published', 'locale' => $locale];
$em = $this->getDoctrine()->getManager();
$pageClass = $this->getParameter('networking_init_cms.manager.page.class');
$params['pages'] = $em->getRepository($pageClass)->findBy($page_filter);
$params['additional_links'] = $this->getAdditionalLinks($locale);
//render xml
$response = $this->render(
'NetworkingInitCmsBundle:Sitemap:sitemap.xml.twig',
$params
);
} else {
//multilanguage site, return language overview sitemap
/* TODO , check if / how "last modified" is possible */
$response = $this->render(
'NetworkingInitCmsBundle:Sitemap:multilingual_sitemap.xml.twig',
$params
);
}
$response->headers->set('Content-Type', 'application/xml');
return $response;
} | php | public function sitemapAction(Request $request, $locale)
{
$params = [];
$params['domain'] = $this->getDomainName($request);
$params['languages'] = $this->container->getParameter('networking_init_cms.page.languages');
if ($locale != '' or count($params['languages']) == 1) {
//sitemap ausgeben
if ($locale == '') { //use locale as default value
$locale = $params['languages']['locale'];
}
$page_filter = ['visibility' => 'public', 'status' => 'status_published', 'locale' => $locale];
$em = $this->getDoctrine()->getManager();
$pageClass = $this->getParameter('networking_init_cms.manager.page.class');
$params['pages'] = $em->getRepository($pageClass)->findBy($page_filter);
$params['additional_links'] = $this->getAdditionalLinks($locale);
//render xml
$response = $this->render(
'NetworkingInitCmsBundle:Sitemap:sitemap.xml.twig',
$params
);
} else {
//multilanguage site, return language overview sitemap
/* TODO , check if / how "last modified" is possible */
$response = $this->render(
'NetworkingInitCmsBundle:Sitemap:multilingual_sitemap.xml.twig',
$params
);
}
$response->headers->set('Content-Type', 'application/xml');
return $response;
} | [
"public",
"function",
"sitemapAction",
"(",
"Request",
"$",
"request",
",",
"$",
"locale",
")",
"{",
"$",
"params",
"=",
"[",
"]",
";",
"$",
"params",
"[",
"'domain'",
"]",
"=",
"$",
"this",
"->",
"getDomainName",
"(",
"$",
"request",
")",
";",
"$",
... | Render the xml Sitemap.
@param Request $request
@return Response | [
"Render",
"the",
"xml",
"Sitemap",
"."
] | 9c6e0f09de216e19795caac5840c197f46fde03d | https://github.com/networking/init-cms-bundle/blob/9c6e0f09de216e19795caac5840c197f46fde03d/src/Controller/XmlController.php#L31-L65 | train |
networking/init-cms-bundle | src/Controller/XmlController.php | XmlController.getDomainName | private function getDomainName(Request $request)
{
$domain = $this->container->getParameter('networking_init_cms.xml_sitemap.sitemap_url');
if ($domain == '') {
//domain is not set in config.yml
$domain = $request->getScheme().'://'.$request->getHost();
}
return $domain;
} | php | private function getDomainName(Request $request)
{
$domain = $this->container->getParameter('networking_init_cms.xml_sitemap.sitemap_url');
if ($domain == '') {
//domain is not set in config.yml
$domain = $request->getScheme().'://'.$request->getHost();
}
return $domain;
} | [
"private",
"function",
"getDomainName",
"(",
"Request",
"$",
"request",
")",
"{",
"$",
"domain",
"=",
"$",
"this",
"->",
"container",
"->",
"getParameter",
"(",
"'networking_init_cms.xml_sitemap.sitemap_url'",
")",
";",
"if",
"(",
"$",
"domain",
"==",
"''",
")... | check config for domain name, otherwise returns scheme & host. | [
"check",
"config",
"for",
"domain",
"name",
"otherwise",
"returns",
"scheme",
"&",
"host",
"."
] | 9c6e0f09de216e19795caac5840c197f46fde03d | https://github.com/networking/init-cms-bundle/blob/9c6e0f09de216e19795caac5840c197f46fde03d/src/Controller/XmlController.php#L86-L95 | train |
networking/init-cms-bundle | src/Model/Page.php | Page.prePersist | public function prePersist()
{
$this->createdAt = $this->updatedAt = new \DateTime('now');
if (!$this->metaTitle) {
$this->setMetaTitle($this->pageName);
}
} | php | public function prePersist()
{
$this->createdAt = $this->updatedAt = new \DateTime('now');
if (!$this->metaTitle) {
$this->setMetaTitle($this->pageName);
}
} | [
"public",
"function",
"prePersist",
"(",
")",
"{",
"$",
"this",
"->",
"createdAt",
"=",
"$",
"this",
"->",
"updatedAt",
"=",
"new",
"\\",
"DateTime",
"(",
"'now'",
")",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"metaTitle",
")",
"{",
"$",
"this",
"->... | Hook on to pre-persist action. | [
"Hook",
"on",
"to",
"pre",
"-",
"persist",
"action",
"."
] | 9c6e0f09de216e19795caac5840c197f46fde03d | https://github.com/networking/init-cms-bundle/blob/9c6e0f09de216e19795caac5840c197f46fde03d/src/Model/Page.php#L181-L188 | train |
networking/init-cms-bundle | src/Model/Page.php | Page.setPageName | public function setPageName($title)
{
$this->oldTitle = $this->pageName;
$this->pageName = $title;
if ($this->pageName && $this->getContentRoute()) {
$this->getContentRoute()->setName($this->pageName);
}
return $this;
} | php | public function setPageName($title)
{
$this->oldTitle = $this->pageName;
$this->pageName = $title;
if ($this->pageName && $this->getContentRoute()) {
$this->getContentRoute()->setName($this->pageName);
}
return $this;
} | [
"public",
"function",
"setPageName",
"(",
"$",
"title",
")",
"{",
"$",
"this",
"->",
"oldTitle",
"=",
"$",
"this",
"->",
"pageName",
";",
"$",
"this",
"->",
"pageName",
"=",
"$",
"title",
";",
"if",
"(",
"$",
"this",
"->",
"pageName",
"&&",
"$",
"t... | Set pageName.
@param string $title
@return $this | [
"Set",
"pageName",
"."
] | 9c6e0f09de216e19795caac5840c197f46fde03d | https://github.com/networking/init-cms-bundle/blob/9c6e0f09de216e19795caac5840c197f46fde03d/src/Model/Page.php#L269-L279 | train |
networking/init-cms-bundle | src/Model/Page.php | Page.setStatus | public function setStatus($status)
{
if (!in_array($status, [self::STATUS_DRAFT, self::STATUS_PUBLISHED, self::STATUS_REVIEW, self::STATUS_OFFLINE])) {
throw new \InvalidArgumentException('Invalid status');
}
$this->status = $status;
return $this;
} | php | public function setStatus($status)
{
if (!in_array($status, [self::STATUS_DRAFT, self::STATUS_PUBLISHED, self::STATUS_REVIEW, self::STATUS_OFFLINE])) {
throw new \InvalidArgumentException('Invalid status');
}
$this->status = $status;
return $this;
} | [
"public",
"function",
"setStatus",
"(",
"$",
"status",
")",
"{",
"if",
"(",
"!",
"in_array",
"(",
"$",
"status",
",",
"[",
"self",
"::",
"STATUS_DRAFT",
",",
"self",
"::",
"STATUS_PUBLISHED",
",",
"self",
"::",
"STATUS_REVIEW",
",",
"self",
"::",
"STATUS... | Set active.
@param string $status
@return $this
@throws \InvalidArgumentException | [
"Set",
"active",
"."
] | 9c6e0f09de216e19795caac5840c197f46fde03d | https://github.com/networking/init-cms-bundle/blob/9c6e0f09de216e19795caac5840c197f46fde03d/src/Model/Page.php#L528-L536 | train |
networking/init-cms-bundle | src/Model/Page.php | Page.setVisibility | public function setVisibility($visibility)
{
if (!in_array($visibility, [self::VISIBILITY_PROTECTED, self::VISIBILITY_PUBLIC])) {
throw new \InvalidArgumentException('Invalid visibility');
}
$this->visibility = $visibility;
return $this;
} | php | public function setVisibility($visibility)
{
if (!in_array($visibility, [self::VISIBILITY_PROTECTED, self::VISIBILITY_PUBLIC])) {
throw new \InvalidArgumentException('Invalid visibility');
}
$this->visibility = $visibility;
return $this;
} | [
"public",
"function",
"setVisibility",
"(",
"$",
"visibility",
")",
"{",
"if",
"(",
"!",
"in_array",
"(",
"$",
"visibility",
",",
"[",
"self",
"::",
"VISIBILITY_PROTECTED",
",",
"self",
"::",
"VISIBILITY_PUBLIC",
"]",
")",
")",
"{",
"throw",
"new",
"\\",
... | Set page visibility.
@param string $visibility
@return $this
@throws \InvalidArgumentException | [
"Set",
"page",
"visibility",
"."
] | 9c6e0f09de216e19795caac5840c197f46fde03d | https://github.com/networking/init-cms-bundle/blob/9c6e0f09de216e19795caac5840c197f46fde03d/src/Model/Page.php#L557-L565 | train |
networking/init-cms-bundle | src/Model/Page.php | Page.addLayoutBlock | public function addLayoutBlock(LayoutBlockInterface $layoutBlock)
{
$layoutBlock->setPage($this);
$this->layoutBlock->add($layoutBlock);
return $this;
} | php | public function addLayoutBlock(LayoutBlockInterface $layoutBlock)
{
$layoutBlock->setPage($this);
$this->layoutBlock->add($layoutBlock);
return $this;
} | [
"public",
"function",
"addLayoutBlock",
"(",
"LayoutBlockInterface",
"$",
"layoutBlock",
")",
"{",
"$",
"layoutBlock",
"->",
"setPage",
"(",
"$",
"this",
")",
";",
"$",
"this",
"->",
"layoutBlock",
"->",
"add",
"(",
"$",
"layoutBlock",
")",
";",
"return",
... | Add layout block.
@param LayoutBlockInterface $layoutBlock
@return $this | [
"Add",
"layout",
"block",
"."
] | 9c6e0f09de216e19795caac5840c197f46fde03d | https://github.com/networking/init-cms-bundle/blob/9c6e0f09de216e19795caac5840c197f46fde03d/src/Model/Page.php#L698-L704 | train |
networking/init-cms-bundle | src/Model/Page.php | Page.resetLayoutBlock | public function resetLayoutBlock($publishedBlocks)
{
$blocksToRemove = $this->layoutBlock->filter(function(LayoutBlock $originalBlock) use($publishedBlocks){
$toRemove = true;
foreach ($publishedBlocks as $block){
if(!$block->getId()){
$toRemove = false;
}
if($block->getId() == $originalBlock->getId()){
$toRemove = false;
}
}
return $toRemove;
});
foreach ($blocksToRemove as $block) {
$block->setNoAutoDraft(true);
$this->layoutBlock->removeElement($block);
}
} | php | public function resetLayoutBlock($publishedBlocks)
{
$blocksToRemove = $this->layoutBlock->filter(function(LayoutBlock $originalBlock) use($publishedBlocks){
$toRemove = true;
foreach ($publishedBlocks as $block){
if(!$block->getId()){
$toRemove = false;
}
if($block->getId() == $originalBlock->getId()){
$toRemove = false;
}
}
return $toRemove;
});
foreach ($blocksToRemove as $block) {
$block->setNoAutoDraft(true);
$this->layoutBlock->removeElement($block);
}
} | [
"public",
"function",
"resetLayoutBlock",
"(",
"$",
"publishedBlocks",
")",
"{",
"$",
"blocksToRemove",
"=",
"$",
"this",
"->",
"layoutBlock",
"->",
"filter",
"(",
"function",
"(",
"LayoutBlock",
"$",
"originalBlock",
")",
"use",
"(",
"$",
"publishedBlocks",
"... | Remove all layout blocks and replace with those in the
serialized page snapshot.
@param ArrayCollection $publishedBlocks | [
"Remove",
"all",
"layout",
"blocks",
"and",
"replace",
"with",
"those",
"in",
"the",
"serialized",
"page",
"snapshot",
"."
] | 9c6e0f09de216e19795caac5840c197f46fde03d | https://github.com/networking/init-cms-bundle/blob/9c6e0f09de216e19795caac5840c197f46fde03d/src/Model/Page.php#L726-L749 | train |
networking/init-cms-bundle | src/Model/Page.php | Page.getLayoutBlock | public function getLayoutBlock($zone = null)
{
if (!is_null($zone)) {
$layoutBlocks = $this->layoutBlock->filter(
function ($layoutBlock) use ($zone) {
return $layoutBlock->getZone() == $zone && $layoutBlock->isActive();
}
);
return array_merge($layoutBlocks->toArray());
}
return $this->layoutBlock;
} | php | public function getLayoutBlock($zone = null)
{
if (!is_null($zone)) {
$layoutBlocks = $this->layoutBlock->filter(
function ($layoutBlock) use ($zone) {
return $layoutBlock->getZone() == $zone && $layoutBlock->isActive();
}
);
return array_merge($layoutBlocks->toArray());
}
return $this->layoutBlock;
} | [
"public",
"function",
"getLayoutBlock",
"(",
"$",
"zone",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"is_null",
"(",
"$",
"zone",
")",
")",
"{",
"$",
"layoutBlocks",
"=",
"$",
"this",
"->",
"layoutBlock",
"->",
"filter",
"(",
"function",
"(",
"$",
"layou... | Get menuItem.
@param null $zone
@return \Doctrine\Common\Collections\ArrayCollection|\Doctrine\Common\Collections\Collection | [
"Get",
"menuItem",
"."
] | 9c6e0f09de216e19795caac5840c197f46fde03d | https://github.com/networking/init-cms-bundle/blob/9c6e0f09de216e19795caac5840c197f46fde03d/src/Model/Page.php#L800-L813 | train |
networking/init-cms-bundle | src/Model/Page.php | Page.setMenuItem | public function setMenuItem(MenuItemInterface $menuItem)
{
$menuItem->setPage($this);
$this->menuItem = $menuItem;
return $this;
} | php | public function setMenuItem(MenuItemInterface $menuItem)
{
$menuItem->setPage($this);
$this->menuItem = $menuItem;
return $this;
} | [
"public",
"function",
"setMenuItem",
"(",
"MenuItemInterface",
"$",
"menuItem",
")",
"{",
"$",
"menuItem",
"->",
"setPage",
"(",
"$",
"this",
")",
";",
"$",
"this",
"->",
"menuItem",
"=",
"$",
"menuItem",
";",
"return",
"$",
"this",
";",
"}"
] | Add menuItem.
@param MenuItemInterface $menuItem
@return $this | [
"Add",
"menuItem",
"."
] | 9c6e0f09de216e19795caac5840c197f46fde03d | https://github.com/networking/init-cms-bundle/blob/9c6e0f09de216e19795caac5840c197f46fde03d/src/Model/Page.php#L822-L828 | train |
networking/init-cms-bundle | src/Model/Page.php | Page.getRecursiveTranslations | public function getRecursiveTranslations(&$translationsArray)
{
// find all possible translations
if (!$this->getTranslations()->isEmpty()) {
foreach ($this->getTranslations() as $translation) {
if ($translation) {
// if we already meet you stop and go on with the next
$translationsArray[$translation->getLocale()] = $translation;
$translation->getRecursiveTranslations($translationsArray);
}
}
}
// find all possible originals
if (!$this->getOriginals()->isEmpty()) {
foreach ($this->getOriginals() as $translation) {
// if we already meet you stop and go on with the next
if (array_key_exists($translation->getLocale(), $translationsArray)) {
return;
}
$translationsArray[$translation->getLocale()] = $translation;
$translation->getRecursiveTranslations($translationsArray);
}
}
} | php | public function getRecursiveTranslations(&$translationsArray)
{
// find all possible translations
if (!$this->getTranslations()->isEmpty()) {
foreach ($this->getTranslations() as $translation) {
if ($translation) {
// if we already meet you stop and go on with the next
$translationsArray[$translation->getLocale()] = $translation;
$translation->getRecursiveTranslations($translationsArray);
}
}
}
// find all possible originals
if (!$this->getOriginals()->isEmpty()) {
foreach ($this->getOriginals() as $translation) {
// if we already meet you stop and go on with the next
if (array_key_exists($translation->getLocale(), $translationsArray)) {
return;
}
$translationsArray[$translation->getLocale()] = $translation;
$translation->getRecursiveTranslations($translationsArray);
}
}
} | [
"public",
"function",
"getRecursiveTranslations",
"(",
"&",
"$",
"translationsArray",
")",
"{",
"// find all possible translations",
"if",
"(",
"!",
"$",
"this",
"->",
"getTranslations",
"(",
")",
"->",
"isEmpty",
"(",
")",
")",
"{",
"foreach",
"(",
"$",
"this... | Recursively search for all possible translations of this page, either originals
of this page, translations of this page or translations of the original of this page.
@param array $translationsArray
@return array | [
"Recursively",
"search",
"for",
"all",
"possible",
"translations",
"of",
"this",
"page",
"either",
"originals",
"of",
"this",
"page",
"translations",
"of",
"this",
"page",
"or",
"translations",
"of",
"the",
"original",
"of",
"this",
"page",
"."
] | 9c6e0f09de216e19795caac5840c197f46fde03d | https://github.com/networking/init-cms-bundle/blob/9c6e0f09de216e19795caac5840c197f46fde03d/src/Model/Page.php#L1253-L1277 | train |
networking/init-cms-bundle | src/EventListener/LocaleListener.php | LocaleListener.guessFrontendLocale | protected function guessFrontendLocale($locales)
{
// search for match in array
if (is_array($locales)) {
foreach ($locales as $locale) {
$match = $this->matchLocaleInAvailableLanguages($locale);
if (strlen($match) > 0) {
return $match;
}
}
} // check if locale matches in available languages
else {
$match = $this->matchLocaleInAvailableLanguages($locales);
if (strlen($match) > 0) {
return $match;
}
}
return $this->defaultLocale;
} | php | protected function guessFrontendLocale($locales)
{
// search for match in array
if (is_array($locales)) {
foreach ($locales as $locale) {
$match = $this->matchLocaleInAvailableLanguages($locale);
if (strlen($match) > 0) {
return $match;
}
}
} // check if locale matches in available languages
else {
$match = $this->matchLocaleInAvailableLanguages($locales);
if (strlen($match) > 0) {
return $match;
}
}
return $this->defaultLocale;
} | [
"protected",
"function",
"guessFrontendLocale",
"(",
"$",
"locales",
")",
"{",
"// search for match in array",
"if",
"(",
"is_array",
"(",
"$",
"locales",
")",
")",
"{",
"foreach",
"(",
"$",
"locales",
"as",
"$",
"locale",
")",
"{",
"$",
"match",
"=",
"$",... | guess frontend locale.
@param mixed $locales
@return string | [
"guess",
"frontend",
"locale",
"."
] | 9c6e0f09de216e19795caac5840c197f46fde03d | https://github.com/networking/init-cms-bundle/blob/9c6e0f09de216e19795caac5840c197f46fde03d/src/EventListener/LocaleListener.php#L202-L221 | train |
networking/init-cms-bundle | src/EventListener/LocaleListener.php | LocaleListener.matchLocaleInAvailableLanguages | protected function matchLocaleInAvailableLanguages($locale)
{
foreach ($this->availableLanguages as $language) {
// browser accept language matches an available language
if ($locale == $language['locale']) {
return $language['locale'];
}
// first part of browser accept language matches an available language
if (substr($locale, 0, 2) == substr($language['locale'], 0, 2)) {
return $language['locale'];
}
}
return false;
} | php | protected function matchLocaleInAvailableLanguages($locale)
{
foreach ($this->availableLanguages as $language) {
// browser accept language matches an available language
if ($locale == $language['locale']) {
return $language['locale'];
}
// first part of browser accept language matches an available language
if (substr($locale, 0, 2) == substr($language['locale'], 0, 2)) {
return $language['locale'];
}
}
return false;
} | [
"protected",
"function",
"matchLocaleInAvailableLanguages",
"(",
"$",
"locale",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"availableLanguages",
"as",
"$",
"language",
")",
"{",
"// browser accept language matches an available language",
"if",
"(",
"$",
"locale",
"=... | try to match browser language with available languages.
@param $locale
@return string | [
"try",
"to",
"match",
"browser",
"language",
"with",
"available",
"languages",
"."
] | 9c6e0f09de216e19795caac5840c197f46fde03d | https://github.com/networking/init-cms-bundle/blob/9c6e0f09de216e19795caac5840c197f46fde03d/src/EventListener/LocaleListener.php#L230-L244 | train |
networking/init-cms-bundle | src/EventListener/LocaleListener.php | LocaleListener.getPreferredLocale | public function getPreferredLocale(Request $request)
{
$browserAcceptLanguages = $this->getBrowserAcceptLanguages($request);
if (empty($browserAcceptLanguages)) {
return $this->defaultLocale;
}
return $this->guessFrontendLocale($browserAcceptLanguages);
} | php | public function getPreferredLocale(Request $request)
{
$browserAcceptLanguages = $this->getBrowserAcceptLanguages($request);
if (empty($browserAcceptLanguages)) {
return $this->defaultLocale;
}
return $this->guessFrontendLocale($browserAcceptLanguages);
} | [
"public",
"function",
"getPreferredLocale",
"(",
"Request",
"$",
"request",
")",
"{",
"$",
"browserAcceptLanguages",
"=",
"$",
"this",
"->",
"getBrowserAcceptLanguages",
"(",
"$",
"request",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"browserAcceptLanguages",
")",
... | get preferred locale.
@param \Symfony\Component\HttpFoundation\Request $request
@return string | [
"get",
"preferred",
"locale",
"."
] | 9c6e0f09de216e19795caac5840c197f46fde03d | https://github.com/networking/init-cms-bundle/blob/9c6e0f09de216e19795caac5840c197f46fde03d/src/EventListener/LocaleListener.php#L253-L261 | train |
networking/init-cms-bundle | src/EventListener/LocaleListener.php | LocaleListener.getBrowserAcceptLanguages | public function getBrowserAcceptLanguages(Request $request)
{
$browserLanguages = [];
if (strlen($request->server->get('HTTP_ACCEPT_LANGUAGE')) == 0) {
return [];
}
$languages = $this->splitHttpAcceptHeader(
$request->server->get('HTTP_ACCEPT_LANGUAGE')
);
foreach ($languages as $lang) {
if (strstr($lang, '-')) {
$codes = explode('-', $lang);
if ($codes[0] == 'i') {
// Language not listed in ISO 639 that are not variants
// of any listed language, which can be registered with the
// i-prefix, such as i-cherokee
if (count($codes) > 1) {
$lang = $codes[1];
}
} else {
for ($i = 0, $max = count($codes); $i < $max; ++$i) {
if ($i == 0) {
$lang = strtolower($codes[0]);
} else {
$lang .= '_'.strtoupper($codes[$i]);
}
}
}
}
$browserLanguages[] = $lang;
}
return $browserLanguages;
} | php | public function getBrowserAcceptLanguages(Request $request)
{
$browserLanguages = [];
if (strlen($request->server->get('HTTP_ACCEPT_LANGUAGE')) == 0) {
return [];
}
$languages = $this->splitHttpAcceptHeader(
$request->server->get('HTTP_ACCEPT_LANGUAGE')
);
foreach ($languages as $lang) {
if (strstr($lang, '-')) {
$codes = explode('-', $lang);
if ($codes[0] == 'i') {
// Language not listed in ISO 639 that are not variants
// of any listed language, which can be registered with the
// i-prefix, such as i-cherokee
if (count($codes) > 1) {
$lang = $codes[1];
}
} else {
for ($i = 0, $max = count($codes); $i < $max; ++$i) {
if ($i == 0) {
$lang = strtolower($codes[0]);
} else {
$lang .= '_'.strtoupper($codes[$i]);
}
}
}
}
$browserLanguages[] = $lang;
}
return $browserLanguages;
} | [
"public",
"function",
"getBrowserAcceptLanguages",
"(",
"Request",
"$",
"request",
")",
"{",
"$",
"browserLanguages",
"=",
"[",
"]",
";",
"if",
"(",
"strlen",
"(",
"$",
"request",
"->",
"server",
"->",
"get",
"(",
"'HTTP_ACCEPT_LANGUAGE'",
")",
")",
"==",
... | get browser accept languages.
@param \Symfony\Component\HttpFoundation\Request $request
@return array | [
"get",
"browser",
"accept",
"languages",
"."
] | 9c6e0f09de216e19795caac5840c197f46fde03d | https://github.com/networking/init-cms-bundle/blob/9c6e0f09de216e19795caac5840c197f46fde03d/src/EventListener/LocaleListener.php#L270-L306 | train |
networking/init-cms-bundle | src/EventListener/LocaleListener.php | LocaleListener.splitHttpAcceptHeader | public function splitHttpAcceptHeader($header)
{
$values = [];
foreach (array_filter(explode(',', $header)) as $value) {
// Cut off any q-value that might come after a semi-colon
if ($pos = strpos($value, ';')) {
$q = (float) trim(substr($value, strpos($value, '=') + 1));
$value = substr($value, 0, $pos);
} else {
$q = 1;
}
if (0 < $q) {
$values[trim($value)] = $q;
}
}
arsort($values);
return array_keys($values);
} | php | public function splitHttpAcceptHeader($header)
{
$values = [];
foreach (array_filter(explode(',', $header)) as $value) {
// Cut off any q-value that might come after a semi-colon
if ($pos = strpos($value, ';')) {
$q = (float) trim(substr($value, strpos($value, '=') + 1));
$value = substr($value, 0, $pos);
} else {
$q = 1;
}
if (0 < $q) {
$values[trim($value)] = $q;
}
}
arsort($values);
return array_keys($values);
} | [
"public",
"function",
"splitHttpAcceptHeader",
"(",
"$",
"header",
")",
"{",
"$",
"values",
"=",
"[",
"]",
";",
"foreach",
"(",
"array_filter",
"(",
"explode",
"(",
"','",
",",
"$",
"header",
")",
")",
"as",
"$",
"value",
")",
"{",
"// Cut off any q-valu... | split http accept header.
@param string $header
@return array | [
"split",
"http",
"accept",
"header",
"."
] | 9c6e0f09de216e19795caac5840c197f46fde03d | https://github.com/networking/init-cms-bundle/blob/9c6e0f09de216e19795caac5840c197f46fde03d/src/EventListener/LocaleListener.php#L315-L335 | train |
networking/init-cms-bundle | src/Menu/FrontendMenuBuilder.php | FrontendMenuBuilder.createSubnavMenu | public function createSubnavMenu($menuName, $classes = 'nav nav-tabs nav-stacked')
{
$menu = $this->factory->createItem('root');
if ($classes) {
$menu->setChildrenAttribute('class', $classes);
}
/** @var $mainMenu Menu */
$menuIterator = $this->getSubMenu($menuName, 1);
if (!$menuIterator) {
return $menu;
}
$startDepth = 2;
$menu = $this->createMenu($menu, $menuIterator, $startDepth);
$this->showOnlyCurrentChildren($menu);
$this->setRecursiveAttribute($menu, ['class' => 'nav nav-list']);
return $menu;
} | php | public function createSubnavMenu($menuName, $classes = 'nav nav-tabs nav-stacked')
{
$menu = $this->factory->createItem('root');
if ($classes) {
$menu->setChildrenAttribute('class', $classes);
}
/** @var $mainMenu Menu */
$menuIterator = $this->getSubMenu($menuName, 1);
if (!$menuIterator) {
return $menu;
}
$startDepth = 2;
$menu = $this->createMenu($menu, $menuIterator, $startDepth);
$this->showOnlyCurrentChildren($menu);
$this->setRecursiveAttribute($menu, ['class' => 'nav nav-list']);
return $menu;
} | [
"public",
"function",
"createSubnavMenu",
"(",
"$",
"menuName",
",",
"$",
"classes",
"=",
"'nav nav-tabs nav-stacked'",
")",
"{",
"$",
"menu",
"=",
"$",
"this",
"->",
"factory",
"->",
"createItem",
"(",
"'root'",
")",
";",
"if",
"(",
"$",
"classes",
")",
... | Create frontend sub navigation on the left hand side of the screen.
@param string $menuName
@param string $classes
@return bool|\Knp\Menu\ItemInterface | [
"Create",
"frontend",
"sub",
"navigation",
"on",
"the",
"left",
"hand",
"side",
"of",
"the",
"screen",
"."
] | 9c6e0f09de216e19795caac5840c197f46fde03d | https://github.com/networking/init-cms-bundle/blob/9c6e0f09de216e19795caac5840c197f46fde03d/src/Menu/FrontendMenuBuilder.php#L60-L82 | train |
networking/init-cms-bundle | src/Menu/FrontendMenuBuilder.php | FrontendMenuBuilder.createFooterMenu | public function createFooterMenu($menuName, $classes = '')
{
$menu = $this->factory->createItem($menuName);
if ($classes) {
$menu->setChildrenAttribute('class', $classes);
}
/** @var $mainMenu Menu */
$menuIterator = $this->getFullMenu($menuName);
if (!$menuIterator) {
return $menu;
}
$startDepth = 1;
$menu = $this->createMenu($menu, $menuIterator, $startDepth);
return $menu;
} | php | public function createFooterMenu($menuName, $classes = '')
{
$menu = $this->factory->createItem($menuName);
if ($classes) {
$menu->setChildrenAttribute('class', $classes);
}
/** @var $mainMenu Menu */
$menuIterator = $this->getFullMenu($menuName);
if (!$menuIterator) {
return $menu;
}
$startDepth = 1;
$menu = $this->createMenu($menu, $menuIterator, $startDepth);
return $menu;
} | [
"public",
"function",
"createFooterMenu",
"(",
"$",
"menuName",
",",
"$",
"classes",
"=",
"''",
")",
"{",
"$",
"menu",
"=",
"$",
"this",
"->",
"factory",
"->",
"createItem",
"(",
"$",
"menuName",
")",
";",
"if",
"(",
"$",
"classes",
")",
"{",
"$",
... | Used to create a simple navigation for the footer.
@param $menuName
@param string $classes
@return \Knp\Menu\ItemInterface | [
"Used",
"to",
"create",
"a",
"simple",
"navigation",
"for",
"the",
"footer",
"."
] | 9c6e0f09de216e19795caac5840c197f46fde03d | https://github.com/networking/init-cms-bundle/blob/9c6e0f09de216e19795caac5840c197f46fde03d/src/Menu/FrontendMenuBuilder.php#L122-L140 | train |
networking/init-cms-bundle | src/Menu/FrontendMenuBuilder.php | FrontendMenuBuilder.createDropdownLangMenu | public function createDropdownLangMenu(
\Knp\Menu\ItemInterface &$menu,
array $languages,
$currentLanguage,
$route = 'networking_init_change_language'
) {
$dropdown = $menu->addChild(
$this->translator->trans('Change Language'),
['dropdown' => true, 'icon' => 'caret']
);
foreach ($languages as $language) {
$node = $dropdown->addChild(
$language['label'],
['uri' => $this->router->generate($route, ['oldLocale' => $this->request->getLocale(), 'locale' => $language['locale']])]
);
if ($language['locale'] == $currentLanguage) {
$node->setCurrent(true);
}
$node->setExtra('translation_domain', false);
}
} | php | public function createDropdownLangMenu(
\Knp\Menu\ItemInterface &$menu,
array $languages,
$currentLanguage,
$route = 'networking_init_change_language'
) {
$dropdown = $menu->addChild(
$this->translator->trans('Change Language'),
['dropdown' => true, 'icon' => 'caret']
);
foreach ($languages as $language) {
$node = $dropdown->addChild(
$language['label'],
['uri' => $this->router->generate($route, ['oldLocale' => $this->request->getLocale(), 'locale' => $language['locale']])]
);
if ($language['locale'] == $currentLanguage) {
$node->setCurrent(true);
}
$node->setExtra('translation_domain', false);
}
} | [
"public",
"function",
"createDropdownLangMenu",
"(",
"\\",
"Knp",
"\\",
"Menu",
"\\",
"ItemInterface",
"&",
"$",
"menu",
",",
"array",
"$",
"languages",
",",
"$",
"currentLanguage",
",",
"$",
"route",
"=",
"'networking_init_change_language'",
")",
"{",
"$",
"d... | Used to create nodes for the language navigation in the front- and backend.
@param \Knp\Menu\ItemInterface $menu
@param array $languages
@param $currentLanguage
@param string $route | [
"Used",
"to",
"create",
"nodes",
"for",
"the",
"language",
"navigation",
"in",
"the",
"front",
"-",
"and",
"backend",
"."
] | 9c6e0f09de216e19795caac5840c197f46fde03d | https://github.com/networking/init-cms-bundle/blob/9c6e0f09de216e19795caac5840c197f46fde03d/src/Menu/FrontendMenuBuilder.php#L150-L172 | train |
networking/init-cms-bundle | src/Controller/CRUDController.php | CRUDController.configure | public function configure()
{
parent::configure();
/** @var \Symfony\Component\HttpFoundation\Session\Session $session */
$session = $this->get('session');
switch (strtolower($this->container->getParameter('networking_init_cms.db_driver'))) {
case 'monodb':
$lastEditedSubscriber = new ODMLastEditedListener($session);
break;
case 'orm':
$lastEditedSubscriber = new ORMLastEditedListener($session);
break;
default:
$lastEditedSubscriber = false;
break;
}
if ($lastEditedSubscriber) {
$this->dispatcher->addSubscriber($lastEditedSubscriber);
}
} | php | public function configure()
{
parent::configure();
/** @var \Symfony\Component\HttpFoundation\Session\Session $session */
$session = $this->get('session');
switch (strtolower($this->container->getParameter('networking_init_cms.db_driver'))) {
case 'monodb':
$lastEditedSubscriber = new ODMLastEditedListener($session);
break;
case 'orm':
$lastEditedSubscriber = new ORMLastEditedListener($session);
break;
default:
$lastEditedSubscriber = false;
break;
}
if ($lastEditedSubscriber) {
$this->dispatcher->addSubscriber($lastEditedSubscriber);
}
} | [
"public",
"function",
"configure",
"(",
")",
"{",
"parent",
"::",
"configure",
"(",
")",
";",
"/** @var \\Symfony\\Component\\HttpFoundation\\Session\\Session $session */",
"$",
"session",
"=",
"$",
"this",
"->",
"get",
"(",
"'session'",
")",
";",
"switch",
"(",
"... | Set up the lasted edited dispatcher. | [
"Set",
"up",
"the",
"lasted",
"edited",
"dispatcher",
"."
] | 9c6e0f09de216e19795caac5840c197f46fde03d | https://github.com/networking/init-cms-bundle/blob/9c6e0f09de216e19795caac5840c197f46fde03d/src/Controller/CRUDController.php#L47-L69 | train |
networking/init-cms-bundle | src/Controller/MediaController.php | MediaController.viewImageAction | public function viewImageAction(Request $request, $id, $format = MediaProviderInterface::FORMAT_REFERENCE)
{
$media = $this->getMedia($id);
if (!$media) {
throw new NotFoundHttpException(sprintf('unable to find the media with the id : %s', $id));
}
if (!$this->get('sonata.media.pool')->getDownloadStrategy($media)->isGranted($media, $request)) {
throw new AccessDeniedException();
}
$provider = $this->getProvider($media);
return new RedirectResponse($provider->generatePublicUrl($media, $format));
} | php | public function viewImageAction(Request $request, $id, $format = MediaProviderInterface::FORMAT_REFERENCE)
{
$media = $this->getMedia($id);
if (!$media) {
throw new NotFoundHttpException(sprintf('unable to find the media with the id : %s', $id));
}
if (!$this->get('sonata.media.pool')->getDownloadStrategy($media)->isGranted($media, $request)) {
throw new AccessDeniedException();
}
$provider = $this->getProvider($media);
return new RedirectResponse($provider->generatePublicUrl($media, $format));
} | [
"public",
"function",
"viewImageAction",
"(",
"Request",
"$",
"request",
",",
"$",
"id",
",",
"$",
"format",
"=",
"MediaProviderInterface",
"::",
"FORMAT_REFERENCE",
")",
"{",
"$",
"media",
"=",
"$",
"this",
"->",
"getMedia",
"(",
"$",
"id",
")",
";",
"i... | output image direct to browser, retrieve from cache if activated.
@param Request $request
@param $id
@param string $format
@return Response | [
"output",
"image",
"direct",
"to",
"browser",
"retrieve",
"from",
"cache",
"if",
"activated",
"."
] | 9c6e0f09de216e19795caac5840c197f46fde03d | https://github.com/networking/init-cms-bundle/blob/9c6e0f09de216e19795caac5840c197f46fde03d/src/Controller/MediaController.php#L32-L46 | train |
networking/init-cms-bundle | src/Controller/CmsHelperController.php | CmsHelperController.setAdminPortalWidthAction | public function setAdminPortalWidthAction(Request $request)
{
$size = $request->get('size', 'full');
/** @var \Networking\InitCmsBundle\Model\UserInterface $user */
$user = $this->getUser();
$status = 200;
$message = 'OK';
try {
$user->setLastActivity(new \DateTime());
$user->setAdminSetting('admin_portal_width', $size);
/** @var \FOS\UserBundle\Doctrine\UserManager $userManager */
$userManager = $this->get('fos_user.user_manager');
$userManager->updateUser($user);
} catch (\Exception $e) {
$status = 500;
$message = $e->getMessage();
}
return new JsonResponse(['message' => $message, 'size' => $size, 'admin_portal_width' => $user->getAdminSetting('admin_portal_width')], $status);
} | php | public function setAdminPortalWidthAction(Request $request)
{
$size = $request->get('size', 'full');
/** @var \Networking\InitCmsBundle\Model\UserInterface $user */
$user = $this->getUser();
$status = 200;
$message = 'OK';
try {
$user->setLastActivity(new \DateTime());
$user->setAdminSetting('admin_portal_width', $size);
/** @var \FOS\UserBundle\Doctrine\UserManager $userManager */
$userManager = $this->get('fos_user.user_manager');
$userManager->updateUser($user);
} catch (\Exception $e) {
$status = 500;
$message = $e->getMessage();
}
return new JsonResponse(['message' => $message, 'size' => $size, 'admin_portal_width' => $user->getAdminSetting('admin_portal_width')], $status);
} | [
"public",
"function",
"setAdminPortalWidthAction",
"(",
"Request",
"$",
"request",
")",
"{",
"$",
"size",
"=",
"$",
"request",
"->",
"get",
"(",
"'size'",
",",
"'full'",
")",
";",
"/** @var \\Networking\\InitCmsBundle\\Model\\UserInterface $user */",
"$",
"user",
"=... | Set user Admin preferred width.
@param Request $request
@return JsonResponse | [
"Set",
"user",
"Admin",
"preferred",
"width",
"."
] | 9c6e0f09de216e19795caac5840c197f46fde03d | https://github.com/networking/init-cms-bundle/blob/9c6e0f09de216e19795caac5840c197f46fde03d/src/Controller/CmsHelperController.php#L44-L64 | train |
networking/init-cms-bundle | src/EventListener/CacheCleaner.php | CacheCleaner.cleanCache | protected function cleanCache()
{
if ($this->cleanCount < 1) {
++$this->cleanCount;
if (is_object($this->phpCache)) {
$this->phpCache->clean();
}
}
} | php | protected function cleanCache()
{
if ($this->cleanCount < 1) {
++$this->cleanCount;
if (is_object($this->phpCache)) {
$this->phpCache->clean();
}
}
} | [
"protected",
"function",
"cleanCache",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"cleanCount",
"<",
"1",
")",
"{",
"++",
"$",
"this",
"->",
"cleanCount",
";",
"if",
"(",
"is_object",
"(",
"$",
"this",
"->",
"phpCache",
")",
")",
"{",
"$",
"this"... | remove items from the cache and stop after one item. | [
"remove",
"items",
"from",
"the",
"cache",
"and",
"stop",
"after",
"one",
"item",
"."
] | 9c6e0f09de216e19795caac5840c197f46fde03d | https://github.com/networking/init-cms-bundle/blob/9c6e0f09de216e19795caac5840c197f46fde03d/src/EventListener/CacheCleaner.php#L73-L81 | train |
networking/init-cms-bundle | src/Controller/FrontendPageController.php | FrontendPageController.indexAction | public function indexAction(Request $request)
{
/** @var \Networking\InitCmsBundle\Lib\PhpCacheInterface $phpCache */
$phpCache = $this->get('networking_init_cms.lib.php_cache');
/** @var PageSnapshotInterface $page */
$page = $request->get('_content');
$template = $request->get('_template');
if ($template instanceof \Sensio\Bundle\FrameworkExtraBundle\Configuration\Template) {
$template = $template->getTemplate();
}
$user = $this->getUser();
if ($phpCache->isCacheable($request, $user) && $page instanceof PageSnapshotInterface) {
if (!$this->isSnapshotActive($page)) {
throw new NotFoundHttpException();
}
if ($this->getSnapshotVisibility($page) != PageInterface::VISIBILITY_PUBLIC) {
if (false === $this->get('security.authorization_checker')->isGranted('ROLE_USER')) {
throw new AccessDeniedException();
}
}
$updatedAt = $phpCache->get(sprintf('page_%s_created_at', $page->getId()));
$cacheKey = $request->getLocale().$request->getPathInfo();
if ($updatedAt != $page->getSnapshotDate()) {
$phpCache->delete($cacheKey);
}
$response = $phpCache->get($request->getLocale().$request->getPathInfo());
if (!$response || !$response instanceof Response) {
$params = $this->getPageParameters($request);
if ($params instanceof RedirectResponse) {
return $params;
}
$html = $this->renderView(
$template,
$params
);
$response = new Response($html);
$phpCache->set($cacheKey, $response);
$phpCache->set(sprintf('page_%s_created_at', $page->getId()), $page->getSnapshotDate());
} else {
$phpCache->touch($cacheKey);
$phpCache->touch(sprintf('page_%s_created_at', $page->getId()));
}
} else {
$params = $this->getPageParameters($request);
if ($params instanceof RedirectResponse) {
return $params;
}
$html = $this->renderView(
$template,
$params
);
$response = new Response($html);
}
if ($this->getPageHelper()->isAllowLocaleCookie() && !$this->getPageHelper()->isSingleLanguage()) {
$response->headers->setCookie(new Cookie('_locale', $request->getLocale()));
}
return $response;
} | php | public function indexAction(Request $request)
{
/** @var \Networking\InitCmsBundle\Lib\PhpCacheInterface $phpCache */
$phpCache = $this->get('networking_init_cms.lib.php_cache');
/** @var PageSnapshotInterface $page */
$page = $request->get('_content');
$template = $request->get('_template');
if ($template instanceof \Sensio\Bundle\FrameworkExtraBundle\Configuration\Template) {
$template = $template->getTemplate();
}
$user = $this->getUser();
if ($phpCache->isCacheable($request, $user) && $page instanceof PageSnapshotInterface) {
if (!$this->isSnapshotActive($page)) {
throw new NotFoundHttpException();
}
if ($this->getSnapshotVisibility($page) != PageInterface::VISIBILITY_PUBLIC) {
if (false === $this->get('security.authorization_checker')->isGranted('ROLE_USER')) {
throw new AccessDeniedException();
}
}
$updatedAt = $phpCache->get(sprintf('page_%s_created_at', $page->getId()));
$cacheKey = $request->getLocale().$request->getPathInfo();
if ($updatedAt != $page->getSnapshotDate()) {
$phpCache->delete($cacheKey);
}
$response = $phpCache->get($request->getLocale().$request->getPathInfo());
if (!$response || !$response instanceof Response) {
$params = $this->getPageParameters($request);
if ($params instanceof RedirectResponse) {
return $params;
}
$html = $this->renderView(
$template,
$params
);
$response = new Response($html);
$phpCache->set($cacheKey, $response);
$phpCache->set(sprintf('page_%s_created_at', $page->getId()), $page->getSnapshotDate());
} else {
$phpCache->touch($cacheKey);
$phpCache->touch(sprintf('page_%s_created_at', $page->getId()));
}
} else {
$params = $this->getPageParameters($request);
if ($params instanceof RedirectResponse) {
return $params;
}
$html = $this->renderView(
$template,
$params
);
$response = new Response($html);
}
if ($this->getPageHelper()->isAllowLocaleCookie() && !$this->getPageHelper()->isSingleLanguage()) {
$response->headers->setCookie(new Cookie('_locale', $request->getLocale()));
}
return $response;
} | [
"public",
"function",
"indexAction",
"(",
"Request",
"$",
"request",
")",
"{",
"/** @var \\Networking\\InitCmsBundle\\Lib\\PhpCacheInterface $phpCache */",
"$",
"phpCache",
"=",
"$",
"this",
"->",
"get",
"(",
"'networking_init_cms.lib.php_cache'",
")",
";",
"/** @var PageSn... | Render the page.
@param Request $request
@return Response | [
"Render",
"the",
"page",
"."
] | 9c6e0f09de216e19795caac5840c197f46fde03d | https://github.com/networking/init-cms-bundle/blob/9c6e0f09de216e19795caac5840c197f46fde03d/src/Controller/FrontendPageController.php#L59-L130 | train |
networking/init-cms-bundle | src/Controller/FrontendPageController.php | FrontendPageController.getRedirect | public function getRedirect(Request $request, PageInterface $page)
{
if (method_exists($page, 'getAlias') && $page instanceof PageInterface) {
if ($alias = $page->getAlias()) {
$alias->getFullPath();
$baseUrl = $request->getBaseUrl();
$route = ContentRouteManager::generateRoute($alias->getContentRoute(), $alias->getFullPath(), '');
return new RedirectResponse($baseUrl.$route->getPath());
}
}
return false;
} | php | public function getRedirect(Request $request, PageInterface $page)
{
if (method_exists($page, 'getAlias') && $page instanceof PageInterface) {
if ($alias = $page->getAlias()) {
$alias->getFullPath();
$baseUrl = $request->getBaseUrl();
$route = ContentRouteManager::generateRoute($alias->getContentRoute(), $alias->getFullPath(), '');
return new RedirectResponse($baseUrl.$route->getPath());
}
}
return false;
} | [
"public",
"function",
"getRedirect",
"(",
"Request",
"$",
"request",
",",
"PageInterface",
"$",
"page",
")",
"{",
"if",
"(",
"method_exists",
"(",
"$",
"page",
",",
"'getAlias'",
")",
"&&",
"$",
"page",
"instanceof",
"PageInterface",
")",
"{",
"if",
"(",
... | Check if page is an alias for another page.
@param Request $request
@param PageInterface $page
@return bool|RedirectResponse | [
"Check",
"if",
"page",
"is",
"an",
"alias",
"for",
"another",
"page",
"."
] | 9c6e0f09de216e19795caac5840c197f46fde03d | https://github.com/networking/init-cms-bundle/blob/9c6e0f09de216e19795caac5840c197f46fde03d/src/Controller/FrontendPageController.php#L140-L154 | train |
networking/init-cms-bundle | src/Controller/FrontendPageController.php | FrontendPageController.changeLanguageAction | public function changeLanguageAction(Request $request, $oldLocale, $locale)
{
$params = [];
$translationRoute = $this->getTranslationRoute($request->headers->get('referer'), $oldLocale, $locale);
$request->setLocale($locale);
if (!is_array($translationRoute)) {
$routeName = $translationRoute;
} else {
$routeName = $translationRoute['_route'];
unset($translationRoute['_route']);
foreach ($translationRoute as $key => $var) {
$params[$key] = $var;
}
}
$params['_locale'] = $locale;
$parts = parse_url($request->headers->get('referer'));
if (array_key_exists('query', $parts) && $parts['query']) {
parse_str($parts['query'], $query);
$params = array_merge($query, $params);
}
$newURL = $this->get('router')->generate($routeName, $params);
$response = new RedirectResponse($newURL);
if ($this->getPageHelper()->isAllowLocaleCookie()) {
$response->headers->setCookie(new Cookie('_locale', $locale));
}
return $response;
} | php | public function changeLanguageAction(Request $request, $oldLocale, $locale)
{
$params = [];
$translationRoute = $this->getTranslationRoute($request->headers->get('referer'), $oldLocale, $locale);
$request->setLocale($locale);
if (!is_array($translationRoute)) {
$routeName = $translationRoute;
} else {
$routeName = $translationRoute['_route'];
unset($translationRoute['_route']);
foreach ($translationRoute as $key => $var) {
$params[$key] = $var;
}
}
$params['_locale'] = $locale;
$parts = parse_url($request->headers->get('referer'));
if (array_key_exists('query', $parts) && $parts['query']) {
parse_str($parts['query'], $query);
$params = array_merge($query, $params);
}
$newURL = $this->get('router')->generate($routeName, $params);
$response = new RedirectResponse($newURL);
if ($this->getPageHelper()->isAllowLocaleCookie()) {
$response->headers->setCookie(new Cookie('_locale', $locale));
}
return $response;
} | [
"public",
"function",
"changeLanguageAction",
"(",
"Request",
"$",
"request",
",",
"$",
"oldLocale",
",",
"$",
"locale",
")",
"{",
"$",
"params",
"=",
"[",
"]",
";",
"$",
"translationRoute",
"=",
"$",
"this",
"->",
"getTranslationRoute",
"(",
"$",
"request... | Change language in the front end area.
@param Request $request
@param $oldLocale
@param $locale
@return RedirectResponse | [
"Change",
"language",
"in",
"the",
"front",
"end",
"area",
"."
] | 9c6e0f09de216e19795caac5840c197f46fde03d | https://github.com/networking/init-cms-bundle/blob/9c6e0f09de216e19795caac5840c197f46fde03d/src/Controller/FrontendPageController.php#L282-L319 | train |
networking/init-cms-bundle | src/Controller/FrontendPageController.php | FrontendPageController.viewDraftAction | public function viewDraftAction(Request $request, $locale, $path = null)
{
$request->setLocale($locale);
return $this->changeViewMode($request, PageInterface::STATUS_DRAFT, $path);
} | php | public function viewDraftAction(Request $request, $locale, $path = null)
{
$request->setLocale($locale);
return $this->changeViewMode($request, PageInterface::STATUS_DRAFT, $path);
} | [
"public",
"function",
"viewDraftAction",
"(",
"Request",
"$",
"request",
",",
"$",
"locale",
",",
"$",
"path",
"=",
"null",
")",
"{",
"$",
"request",
"->",
"setLocale",
"(",
"$",
"locale",
")",
";",
"return",
"$",
"this",
"->",
"changeViewMode",
"(",
"... | View the website in Draft mode.
@param Request $request
@param string $locale
@param string /null $path
@return RedirectResponse | [
"View",
"the",
"website",
"in",
"Draft",
"mode",
"."
] | 9c6e0f09de216e19795caac5840c197f46fde03d | https://github.com/networking/init-cms-bundle/blob/9c6e0f09de216e19795caac5840c197f46fde03d/src/Controller/FrontendPageController.php#L330-L335 | train |
networking/init-cms-bundle | src/Controller/FrontendPageController.php | FrontendPageController.viewLiveAction | public function viewLiveAction(Request $request, $locale, $path = null)
{
$request->setLocale($locale);
return $this->changeViewMode($request, PageInterface::STATUS_PUBLISHED, $path);
} | php | public function viewLiveAction(Request $request, $locale, $path = null)
{
$request->setLocale($locale);
return $this->changeViewMode($request, PageInterface::STATUS_PUBLISHED, $path);
} | [
"public",
"function",
"viewLiveAction",
"(",
"Request",
"$",
"request",
",",
"$",
"locale",
",",
"$",
"path",
"=",
"null",
")",
"{",
"$",
"request",
"->",
"setLocale",
"(",
"$",
"locale",
")",
";",
"return",
"$",
"this",
"->",
"changeViewMode",
"(",
"$... | View the website in Live mode.
@param Request $request
@param string $locale
@param string /null $path
@return RedirectResponse | [
"View",
"the",
"website",
"in",
"Live",
"mode",
"."
] | 9c6e0f09de216e19795caac5840c197f46fde03d | https://github.com/networking/init-cms-bundle/blob/9c6e0f09de216e19795caac5840c197f46fde03d/src/Controller/FrontendPageController.php#L346-L351 | train |
networking/init-cms-bundle | src/Controller/FrontendPageController.php | FrontendPageController.changeViewMode | protected function changeViewMode(Request $request, $status, $path)
{
if (false === $this->get('security.authorization_checker')->isGranted('ROLE_SONATA_ADMIN')) {
$message = 'Please login to carry out this action';
throw new AccessDeniedException($message);
}
$request->getSession()->set('_viewStatus', $status);
if ($path) {
$url = base64_decode($path);
} else {
$url = $this->get('router')->generate('networking_init_cms_default');
}
return $this->redirect($url);
} | php | protected function changeViewMode(Request $request, $status, $path)
{
if (false === $this->get('security.authorization_checker')->isGranted('ROLE_SONATA_ADMIN')) {
$message = 'Please login to carry out this action';
throw new AccessDeniedException($message);
}
$request->getSession()->set('_viewStatus', $status);
if ($path) {
$url = base64_decode($path);
} else {
$url = $this->get('router')->generate('networking_init_cms_default');
}
return $this->redirect($url);
} | [
"protected",
"function",
"changeViewMode",
"(",
"Request",
"$",
"request",
",",
"$",
"status",
",",
"$",
"path",
")",
"{",
"if",
"(",
"false",
"===",
"$",
"this",
"->",
"get",
"(",
"'security.authorization_checker'",
")",
"->",
"isGranted",
"(",
"'ROLE_SONAT... | Change the page viewing mode to live or draft.
@param Request $request
@param $status
@param $path
@return RedirectResponse
@throws AccessDeniedException | [
"Change",
"the",
"page",
"viewing",
"mode",
"to",
"live",
"or",
"draft",
"."
] | 9c6e0f09de216e19795caac5840c197f46fde03d | https://github.com/networking/init-cms-bundle/blob/9c6e0f09de216e19795caac5840c197f46fde03d/src/Controller/FrontendPageController.php#L364-L380 | train |
networking/init-cms-bundle | src/Controller/FrontendPageController.php | FrontendPageController.getTranslationRoute | protected function getTranslationRoute($referrer, $oldLocale, $locale)
{
/** @var $languageSwitcherHelper LanguageSwitcherHelper */
$languageSwitcherHelper = $this->get('networking_init_cms.page.helper.language_switcher');
$oldURL = $languageSwitcherHelper->getPathInfo($referrer);
return $languageSwitcherHelper->getTranslationRoute($oldURL, $oldLocale, $locale);
} | php | protected function getTranslationRoute($referrer, $oldLocale, $locale)
{
/** @var $languageSwitcherHelper LanguageSwitcherHelper */
$languageSwitcherHelper = $this->get('networking_init_cms.page.helper.language_switcher');
$oldURL = $languageSwitcherHelper->getPathInfo($referrer);
return $languageSwitcherHelper->getTranslationRoute($oldURL, $oldLocale, $locale);
} | [
"protected",
"function",
"getTranslationRoute",
"(",
"$",
"referrer",
",",
"$",
"oldLocale",
",",
"$",
"locale",
")",
"{",
"/** @var $languageSwitcherHelper LanguageSwitcherHelper */",
"$",
"languageSwitcherHelper",
"=",
"$",
"this",
"->",
"get",
"(",
"'networking_init_... | get the route for the translation of a given page, the referrer page.
@param $referrer
@param $oldLocale
@param $locale
@return array|RouteObjectInterface | [
"get",
"the",
"route",
"for",
"the",
"translation",
"of",
"a",
"given",
"page",
"the",
"referrer",
"page",
"."
] | 9c6e0f09de216e19795caac5840c197f46fde03d | https://github.com/networking/init-cms-bundle/blob/9c6e0f09de216e19795caac5840c197f46fde03d/src/Controller/FrontendPageController.php#L391-L399 | train |
networking/init-cms-bundle | src/Controller/FrontendPageController.php | FrontendPageController.adminNavbarAction | public function adminNavbarAction(Request $request, $page_id = null)
{
if ($page_id) {
/** @var \Networking\InitCmsBundle\Entity\PageManager $pageManager */
$pageManager = $this->container->get('networking_init_cms.page_manager');
$page = $pageManager->find($page_id);
$request->attributes->set('_content', $page);
}
$response = $this->render(
'@NetworkingInitCms/Admin/esi_admin_navbar.html.twig',
['admin_pool' => $this->getAdminPool()]
);
// set the shared max age - which also marks the response as public
$response->setSharedMaxAge(10);
return $response;
} | php | public function adminNavbarAction(Request $request, $page_id = null)
{
if ($page_id) {
/** @var \Networking\InitCmsBundle\Entity\PageManager $pageManager */
$pageManager = $this->container->get('networking_init_cms.page_manager');
$page = $pageManager->find($page_id);
$request->attributes->set('_content', $page);
}
$response = $this->render(
'@NetworkingInitCms/Admin/esi_admin_navbar.html.twig',
['admin_pool' => $this->getAdminPool()]
);
// set the shared max age - which also marks the response as public
$response->setSharedMaxAge(10);
return $response;
} | [
"public",
"function",
"adminNavbarAction",
"(",
"Request",
"$",
"request",
",",
"$",
"page_id",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"page_id",
")",
"{",
"/** @var \\Networking\\InitCmsBundle\\Entity\\PageManager $pageManager */",
"$",
"pageManager",
"=",
"$",
"th... | Deliver the admin navigation bar via ajax.
@param null $page_id
@return Response | [
"Deliver",
"the",
"admin",
"navigation",
"bar",
"via",
"ajax",
"."
] | 9c6e0f09de216e19795caac5840c197f46fde03d | https://github.com/networking/init-cms-bundle/blob/9c6e0f09de216e19795caac5840c197f46fde03d/src/Controller/FrontendPageController.php#L431-L449 | train |
networking/init-cms-bundle | src/Controller/HelpTextController.php | HelpTextController.adminHelpAction | public function adminHelpAction(Request $request, $adminCode, $action = '')
{
$parameters = ['adminCode' => $adminCode, 'action' => $action];
$defaultAdminCode = ['dashboard', 'overview'];
if ($action == '') {
$translationKey = $adminCode;
} else {
$translationKey = $adminCode.'.'.$action;
}
$helpTextManager = $this->get('networking_init_cms.help_text_manager');
$helpText = $helpTextManager->getHelpTextByKeyLocale($translationKey, $request->getLocale());
$parameters['help_text'] = $helpText;
if (!in_array($adminCode, $defaultAdminCode)) {
$admin = $this->container->get('sonata.admin.pool')->getAdminByAdminCode($adminCode);
$admin->setRequest($request);
$parameters['admin'] = $admin;
}
/** @var \Networking\InitCmsBundle\Admin\Pool $pool */
$pool = $this->get('sonata.admin.pool');
$parameters['admin_pool'] = $pool;
$parameters['base_template'] = isset($admin) ? $this->getBaseTemplate($request, $admin) : '@NetworkingInitCms/admin_layout.html.twig';
$dashBoardGroups = $pool->getDashboardNavigationGroups();
$parameters['help_nav'] = $this->adminGetHelpTextNavigation(
$dashBoardGroups,
$request->getLocale(),
$helpTextManager
);
return $this->render(
'@NetworkingInitCms/HelpText/adminHelp.html.twig',
$parameters
);
} | php | public function adminHelpAction(Request $request, $adminCode, $action = '')
{
$parameters = ['adminCode' => $adminCode, 'action' => $action];
$defaultAdminCode = ['dashboard', 'overview'];
if ($action == '') {
$translationKey = $adminCode;
} else {
$translationKey = $adminCode.'.'.$action;
}
$helpTextManager = $this->get('networking_init_cms.help_text_manager');
$helpText = $helpTextManager->getHelpTextByKeyLocale($translationKey, $request->getLocale());
$parameters['help_text'] = $helpText;
if (!in_array($adminCode, $defaultAdminCode)) {
$admin = $this->container->get('sonata.admin.pool')->getAdminByAdminCode($adminCode);
$admin->setRequest($request);
$parameters['admin'] = $admin;
}
/** @var \Networking\InitCmsBundle\Admin\Pool $pool */
$pool = $this->get('sonata.admin.pool');
$parameters['admin_pool'] = $pool;
$parameters['base_template'] = isset($admin) ? $this->getBaseTemplate($request, $admin) : '@NetworkingInitCms/admin_layout.html.twig';
$dashBoardGroups = $pool->getDashboardNavigationGroups();
$parameters['help_nav'] = $this->adminGetHelpTextNavigation(
$dashBoardGroups,
$request->getLocale(),
$helpTextManager
);
return $this->render(
'@NetworkingInitCms/HelpText/adminHelp.html.twig',
$parameters
);
} | [
"public",
"function",
"adminHelpAction",
"(",
"Request",
"$",
"request",
",",
"$",
"adminCode",
",",
"$",
"action",
"=",
"''",
")",
"{",
"$",
"parameters",
"=",
"[",
"'adminCode'",
"=>",
"$",
"adminCode",
",",
"'action'",
"=>",
"$",
"action",
"]",
";",
... | Help text page action.
@param Request $request
@param $adminCode
@param string $action
@return \Symfony\Component\HttpFoundation\Response | [
"Help",
"text",
"page",
"action",
"."
] | 9c6e0f09de216e19795caac5840c197f46fde03d | https://github.com/networking/init-cms-bundle/blob/9c6e0f09de216e19795caac5840c197f46fde03d/src/Controller/HelpTextController.php#L33-L70 | train |
networking/init-cms-bundle | src/Controller/HelpTextController.php | HelpTextController.getBaseTemplate | protected function getBaseTemplate(Request $request, AbstractAdmin $admin)
{
if ($request->isXmlHttpRequest()) {
return $admin->getTemplate('ajax');
}
return $admin->getTemplate('layout');
} | php | protected function getBaseTemplate(Request $request, AbstractAdmin $admin)
{
if ($request->isXmlHttpRequest()) {
return $admin->getTemplate('ajax');
}
return $admin->getTemplate('layout');
} | [
"protected",
"function",
"getBaseTemplate",
"(",
"Request",
"$",
"request",
",",
"AbstractAdmin",
"$",
"admin",
")",
"{",
"if",
"(",
"$",
"request",
"->",
"isXmlHttpRequest",
"(",
")",
")",
"{",
"return",
"$",
"admin",
"->",
"getTemplate",
"(",
"'ajax'",
"... | return the base template name.
@param Request $request
@param AbstractAdmin $admin
@return string the template name | [
"return",
"the",
"base",
"template",
"name",
"."
] | 9c6e0f09de216e19795caac5840c197f46fde03d | https://github.com/networking/init-cms-bundle/blob/9c6e0f09de216e19795caac5840c197f46fde03d/src/Controller/HelpTextController.php#L80-L87 | train |
networking/init-cms-bundle | src/Controller/HelpTextController.php | HelpTextController.adminGetHelpTextNavigation | protected function adminGetHelpTextNavigation(array $dashBoardGroups, $locale, $helpTextManager)
{
$navArray = [];
//add overview & dashboard manually
$navArray['overview']['group_name'] = $this->get('translator')->trans(
'title.help',
[],
'HelpTextAdmin'
);
$navArray['overview']['group_items']['0']['adminCode'] = 'overview';
$navArray['overview']['group_items']['0']['action'] = '';
$navArray['overview']['group_items']['0']['title'] = $this->get('translator')->trans(
'overview.title',
[],
'HelpTextAdmin'
);
$navArray['dashboard']['group_name'] = 'Dashboard';
$navArray['dashboard']['group_items']['0']['adminCode'] = 'dashboard';
$navArray['dashboard']['group_items']['0']['action'] = '';
$navArray['dashboard']['group_items']['0']['title'] = $this->get('translator')->trans(
'dashboard.title',
[],
'HelpTextAdmin'
);
foreach ($dashBoardGroups as $key => $group) {
foreach ($group['sub_group'] as $subGroup) {
$navArray[$subGroup['label']]['group_items'] = [];
$i = 0;
foreach ($subGroup['items'] as $admin) {
if (0 == $i++) {
$navArray[$subGroup['label']]['group_name'] = $this->get('translator')->trans(
$subGroup['label'],
[],
$admin->getTranslationDomain()
);
}
$help_text_result = $helpTextManager->searchHelpTextByKeyLocale($admin->getCode(), $locale);
if (count($help_text_result) > 0) {
foreach ($help_text_result as $row) {
//split Translation Key into adminCode and action
$strripos = strripos($row->getTranslationKey(), '.');
$action = substr($row->getTranslationKey(), $strripos + 1);
$navArray[$subGroup['label']]['group_items'][$row->getId()]['adminCode'] = $admin->getCode(
);
$navArray[$subGroup['label']]['group_items'][$row->getId()]['action'] = $action;
$navArray[$subGroup['label']]['group_items'][$row->getId()]['title'] = $row->getTitle();
}
}
}
}
}
return $navArray;
} | php | protected function adminGetHelpTextNavigation(array $dashBoardGroups, $locale, $helpTextManager)
{
$navArray = [];
//add overview & dashboard manually
$navArray['overview']['group_name'] = $this->get('translator')->trans(
'title.help',
[],
'HelpTextAdmin'
);
$navArray['overview']['group_items']['0']['adminCode'] = 'overview';
$navArray['overview']['group_items']['0']['action'] = '';
$navArray['overview']['group_items']['0']['title'] = $this->get('translator')->trans(
'overview.title',
[],
'HelpTextAdmin'
);
$navArray['dashboard']['group_name'] = 'Dashboard';
$navArray['dashboard']['group_items']['0']['adminCode'] = 'dashboard';
$navArray['dashboard']['group_items']['0']['action'] = '';
$navArray['dashboard']['group_items']['0']['title'] = $this->get('translator')->trans(
'dashboard.title',
[],
'HelpTextAdmin'
);
foreach ($dashBoardGroups as $key => $group) {
foreach ($group['sub_group'] as $subGroup) {
$navArray[$subGroup['label']]['group_items'] = [];
$i = 0;
foreach ($subGroup['items'] as $admin) {
if (0 == $i++) {
$navArray[$subGroup['label']]['group_name'] = $this->get('translator')->trans(
$subGroup['label'],
[],
$admin->getTranslationDomain()
);
}
$help_text_result = $helpTextManager->searchHelpTextByKeyLocale($admin->getCode(), $locale);
if (count($help_text_result) > 0) {
foreach ($help_text_result as $row) {
//split Translation Key into adminCode and action
$strripos = strripos($row->getTranslationKey(), '.');
$action = substr($row->getTranslationKey(), $strripos + 1);
$navArray[$subGroup['label']]['group_items'][$row->getId()]['adminCode'] = $admin->getCode(
);
$navArray[$subGroup['label']]['group_items'][$row->getId()]['action'] = $action;
$navArray[$subGroup['label']]['group_items'][$row->getId()]['title'] = $row->getTitle();
}
}
}
}
}
return $navArray;
} | [
"protected",
"function",
"adminGetHelpTextNavigation",
"(",
"array",
"$",
"dashBoardGroups",
",",
"$",
"locale",
",",
"$",
"helpTextManager",
")",
"{",
"$",
"navArray",
"=",
"[",
"]",
";",
"//add overview & dashboard manually",
"$",
"navArray",
"[",
"'overview'",
... | Create the navigation for the help text view.
@param array $dashBoardGroups
@param $locale
@param $helpTextManager
@return array | [
"Create",
"the",
"navigation",
"for",
"the",
"help",
"text",
"view",
"."
] | 9c6e0f09de216e19795caac5840c197f46fde03d | https://github.com/networking/init-cms-bundle/blob/9c6e0f09de216e19795caac5840c197f46fde03d/src/Controller/HelpTextController.php#L98-L155 | train |
networking/init-cms-bundle | src/Controller/MediaAdminController.php | MediaAdminController.redirectTo | public function redirectTo($object)
{
$url = false;
if ($this->getRequest()->get('btn_update_and_list')) {
$url = $this->admin->generateUrl('list', ['active_tab' => $this->getRequest()->get('context')]);
}
if ($this->getRequest()->get('btn_create_and_list')) {
$url = $this->admin->generateUrl('list', ['active_tab' => $this->getRequest()->get('context')]);
}
if ($this->getRequest()->get('btn_create_and_create')) {
$params = [];
if ($this->admin->hasActiveSubClass()) {
$params['subclass'] = $this->getRequest()->get('subclass');
}
$url = $this->admin->generateUrl('create', $params);
}
if (!$url) {
$url = $this->admin->generateObjectUrl('edit', $object);
}
return new RedirectResponse($url);
} | php | public function redirectTo($object)
{
$url = false;
if ($this->getRequest()->get('btn_update_and_list')) {
$url = $this->admin->generateUrl('list', ['active_tab' => $this->getRequest()->get('context')]);
}
if ($this->getRequest()->get('btn_create_and_list')) {
$url = $this->admin->generateUrl('list', ['active_tab' => $this->getRequest()->get('context')]);
}
if ($this->getRequest()->get('btn_create_and_create')) {
$params = [];
if ($this->admin->hasActiveSubClass()) {
$params['subclass'] = $this->getRequest()->get('subclass');
}
$url = $this->admin->generateUrl('create', $params);
}
if (!$url) {
$url = $this->admin->generateObjectUrl('edit', $object);
}
return new RedirectResponse($url);
} | [
"public",
"function",
"redirectTo",
"(",
"$",
"object",
")",
"{",
"$",
"url",
"=",
"false",
";",
"if",
"(",
"$",
"this",
"->",
"getRequest",
"(",
")",
"->",
"get",
"(",
"'btn_update_and_list'",
")",
")",
"{",
"$",
"url",
"=",
"$",
"this",
"->",
"ad... | redirect the user depend on this choice.
@param object $object
@return Response | [
"redirect",
"the",
"user",
"depend",
"on",
"this",
"choice",
"."
] | 9c6e0f09de216e19795caac5840c197f46fde03d | https://github.com/networking/init-cms-bundle/blob/9c6e0f09de216e19795caac5840c197f46fde03d/src/Controller/MediaAdminController.php#L105-L129 | train |
networking/init-cms-bundle | src/Controller/CkeditorAdminController.php | CkeditorAdminController.getTemplate | private function getTemplate($name)
{
$templates = $this->container->getParameter('sonata.formatter.ckeditor.configuration.templates');
if (isset($templates[$name])) {
return $templates[$name];
}
return null;
} | php | private function getTemplate($name)
{
$templates = $this->container->getParameter('sonata.formatter.ckeditor.configuration.templates');
if (isset($templates[$name])) {
return $templates[$name];
}
return null;
} | [
"private",
"function",
"getTemplate",
"(",
"$",
"name",
")",
"{",
"$",
"templates",
"=",
"$",
"this",
"->",
"container",
"->",
"getParameter",
"(",
"'sonata.formatter.ckeditor.configuration.templates'",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"templates",
"[",
... | Returns a template.
@param string $name
@return string | [
"Returns",
"a",
"template",
"."
] | 9c6e0f09de216e19795caac5840c197f46fde03d | https://github.com/networking/init-cms-bundle/blob/9c6e0f09de216e19795caac5840c197f46fde03d/src/Controller/CkeditorAdminController.php#L242-L251 | train |
networking/init-cms-bundle | src/Admin/Pool.php | Pool.getDashboardNavigationGroups | public function getDashboardNavigationGroups()
{
$groups = $this->getDashboardGroups();
$menuGroups = $this->getContainer()->getParameter('networking_init_cms.admin_menu_groups');
foreach ($menuGroups as $key => $menuGroup) {
foreach ($menuGroup['items'] as $k => $item) {
if (array_key_exists($item, $groups)) {
$menuGroups[$key]['sub_group'][$k] = $groups[$item];
}
}
}
return $menuGroups;
} | php | public function getDashboardNavigationGroups()
{
$groups = $this->getDashboardGroups();
$menuGroups = $this->getContainer()->getParameter('networking_init_cms.admin_menu_groups');
foreach ($menuGroups as $key => $menuGroup) {
foreach ($menuGroup['items'] as $k => $item) {
if (array_key_exists($item, $groups)) {
$menuGroups[$key]['sub_group'][$k] = $groups[$item];
}
}
}
return $menuGroups;
} | [
"public",
"function",
"getDashboardNavigationGroups",
"(",
")",
"{",
"$",
"groups",
"=",
"$",
"this",
"->",
"getDashboardGroups",
"(",
")",
";",
"$",
"menuGroups",
"=",
"$",
"this",
"->",
"getContainer",
"(",
")",
"->",
"getParameter",
"(",
"'networking_init_c... | Get the groups of admins that will be used to display the
admin menu on the side.
@return array | [
"Get",
"the",
"groups",
"of",
"admins",
"that",
"will",
"be",
"used",
"to",
"display",
"the",
"admin",
"menu",
"on",
"the",
"side",
"."
] | 9c6e0f09de216e19795caac5840c197f46fde03d | https://github.com/networking/init-cms-bundle/blob/9c6e0f09de216e19795caac5840c197f46fde03d/src/Admin/Pool.php#L28-L43 | train |
networking/init-cms-bundle | src/Model/LayoutBlockFormListener.php | LayoutBlockFormListener.postBindData | public function postBindData(FormEvent $event)
{
/** @var $layoutBlock LayoutBlockInterface */
$layoutBlock = $event->getForm()->getData();
$contentObject = $layoutBlock->getContent();
if (!$contentObject instanceof ContentInterface) {
throw new \RuntimeException('Content Object must implement the ContentInterface');
}
$this->validate($event, $contentObject);
} | php | public function postBindData(FormEvent $event)
{
/** @var $layoutBlock LayoutBlockInterface */
$layoutBlock = $event->getForm()->getData();
$contentObject = $layoutBlock->getContent();
if (!$contentObject instanceof ContentInterface) {
throw new \RuntimeException('Content Object must implement the ContentInterface');
}
$this->validate($event, $contentObject);
} | [
"public",
"function",
"postBindData",
"(",
"FormEvent",
"$",
"event",
")",
"{",
"/** @var $layoutBlock LayoutBlockInterface */",
"$",
"layoutBlock",
"=",
"$",
"event",
"->",
"getForm",
"(",
")",
"->",
"getData",
"(",
")",
";",
"$",
"contentObject",
"=",
"$",
"... | Bind the content type objects variables from the form.
If needed create an new content type object, or change to a new type deleting the old one.
Set the Content objects contentType and objectId fields accordingly.
@param FormEvent $event
@throws \RuntimeException | [
"Bind",
"the",
"content",
"type",
"objects",
"variables",
"from",
"the",
"form",
".",
"If",
"needed",
"create",
"an",
"new",
"content",
"type",
"object",
"or",
"change",
"to",
"a",
"new",
"type",
"deleting",
"the",
"old",
"one",
".",
"Set",
"the",
"Conte... | 9c6e0f09de216e19795caac5840c197f46fde03d | https://github.com/networking/init-cms-bundle/blob/9c6e0f09de216e19795caac5840c197f46fde03d/src/Model/LayoutBlockFormListener.php#L131-L144 | train |
networking/init-cms-bundle | src/Model/LayoutBlockFormListener.php | LayoutBlockFormListener.getContentType | public function getContentType(LayoutBlockInterface $layoutBlock = null)
{
if (is_null($layoutBlock) || !$classType = $layoutBlock->getClassType()) {
if ($this->contentType) {
return $this->contentType;
}
$contentTypes = $this->getContentTypes();
$classType = $contentTypes[0]['class'];
}
return $classType;
} | php | public function getContentType(LayoutBlockInterface $layoutBlock = null)
{
if (is_null($layoutBlock) || !$classType = $layoutBlock->getClassType()) {
if ($this->contentType) {
return $this->contentType;
}
$contentTypes = $this->getContentTypes();
$classType = $contentTypes[0]['class'];
}
return $classType;
} | [
"public",
"function",
"getContentType",
"(",
"LayoutBlockInterface",
"$",
"layoutBlock",
"=",
"null",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"layoutBlock",
")",
"||",
"!",
"$",
"classType",
"=",
"$",
"layoutBlock",
"->",
"getClassType",
"(",
")",
")",
"... | Get the content type of the content object, if the object is new, use the first available type.
@param LayoutBlockInterface $layoutBlock
@return string | [
"Get",
"the",
"content",
"type",
"of",
"the",
"content",
"object",
"if",
"the",
"object",
"is",
"new",
"use",
"the",
"first",
"available",
"type",
"."
] | 9c6e0f09de216e19795caac5840c197f46fde03d | https://github.com/networking/init-cms-bundle/blob/9c6e0f09de216e19795caac5840c197f46fde03d/src/Model/LayoutBlockFormListener.php#L192-L205 | train |
networking/init-cms-bundle | src/Admin/Model/MenuItemAdmin.php | MenuItemAdmin.getTranslatedLinkTargets | public function getTranslatedLinkTargets()
{
$translatedLinkTargets = [];
foreach ($this->linkTargets as $key => $value) {
$translatedLinkTargets[$key] = $value;
}
return $translatedLinkTargets;
} | php | public function getTranslatedLinkTargets()
{
$translatedLinkTargets = [];
foreach ($this->linkTargets as $key => $value) {
$translatedLinkTargets[$key] = $value;
}
return $translatedLinkTargets;
} | [
"public",
"function",
"getTranslatedLinkTargets",
"(",
")",
"{",
"$",
"translatedLinkTargets",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"linkTargets",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"translatedLinkTargets",
"[",
"$",
"ke... | returns all translated link targets.
@return array | [
"returns",
"all",
"translated",
"link",
"targets",
"."
] | 9c6e0f09de216e19795caac5840c197f46fde03d | https://github.com/networking/init-cms-bundle/blob/9c6e0f09de216e19795caac5840c197f46fde03d/src/Admin/Model/MenuItemAdmin.php#L364-L372 | train |
networking/init-cms-bundle | src/Model/LayoutBlock.php | LayoutBlock.setIsActive | public function setIsActive($active)
{
$active = $active ? true : false;
$this->isActive = $active;
return $this;
} | php | public function setIsActive($active)
{
$active = $active ? true : false;
$this->isActive = $active;
return $this;
} | [
"public",
"function",
"setIsActive",
"(",
"$",
"active",
")",
"{",
"$",
"active",
"=",
"$",
"active",
"?",
"true",
":",
"false",
";",
"$",
"this",
"->",
"isActive",
"=",
"$",
"active",
";",
"return",
"$",
"this",
";",
"}"
] | Set isActive.
@param bool $active
@return $this | [
"Set",
"isActive",
"."
] | 9c6e0f09de216e19795caac5840c197f46fde03d | https://github.com/networking/init-cms-bundle/blob/9c6e0f09de216e19795caac5840c197f46fde03d/src/Model/LayoutBlock.php#L276-L282 | train |
networking/init-cms-bundle | src/Controller/AdminResettingController.php | AdminResettingController.sendResettingEmailMessage | private function sendResettingEmailMessage(UserInterface $user): void
{
$url = $this->generateUrl('networking_init_cms_admin_resetting_reset', [
'token' => $user->getConfirmationToken(),
], UrlGeneratorInterface::ABSOLUTE_URL);
$rendered = $this->renderView($this->container->getParameter('fos_user.resetting.email.template'), [
'user' => $user,
'confirmationUrl' => $url,
]);
// Render the email, use the first line as the subject, and the rest as the body
$renderedLines = explode(PHP_EOL, trim($rendered));
$subject = array_shift($renderedLines);
$body = implode(PHP_EOL, $renderedLines);
$message = (new \Swift_Message())
->setSubject($subject)
->setFrom($this->container->getParameter('fos_user.resetting.email.from_email'))
->setTo((string) $user->getEmail())
->setBody($body);
$this->get('mailer')->send($message);
} | php | private function sendResettingEmailMessage(UserInterface $user): void
{
$url = $this->generateUrl('networking_init_cms_admin_resetting_reset', [
'token' => $user->getConfirmationToken(),
], UrlGeneratorInterface::ABSOLUTE_URL);
$rendered = $this->renderView($this->container->getParameter('fos_user.resetting.email.template'), [
'user' => $user,
'confirmationUrl' => $url,
]);
// Render the email, use the first line as the subject, and the rest as the body
$renderedLines = explode(PHP_EOL, trim($rendered));
$subject = array_shift($renderedLines);
$body = implode(PHP_EOL, $renderedLines);
$message = (new \Swift_Message())
->setSubject($subject)
->setFrom($this->container->getParameter('fos_user.resetting.email.from_email'))
->setTo((string) $user->getEmail())
->setBody($body);
$this->get('mailer')->send($message);
} | [
"private",
"function",
"sendResettingEmailMessage",
"(",
"UserInterface",
"$",
"user",
")",
":",
"void",
"{",
"$",
"url",
"=",
"$",
"this",
"->",
"generateUrl",
"(",
"'networking_init_cms_admin_resetting_reset'",
",",
"[",
"'token'",
"=>",
"$",
"user",
"->",
"ge... | Send an email to a user to confirm the password reset.
@param UserInterface $user | [
"Send",
"an",
"email",
"to",
"a",
"user",
"to",
"confirm",
"the",
"password",
"reset",
"."
] | 9c6e0f09de216e19795caac5840c197f46fde03d | https://github.com/networking/init-cms-bundle/blob/9c6e0f09de216e19795caac5840c197f46fde03d/src/Controller/AdminResettingController.php#L178-L199 | train |
networking/init-cms-bundle | src/Helper/LanguageSwitcherHelper.php | LanguageSwitcherHelper.getQueryString | public function getQueryString()
{
$qs = Request::normalizeQueryString($this->requestStack->getCurrentRequest()->server->get('QUERY_STRING'));
return '' === $qs ? null : $qs;
} | php | public function getQueryString()
{
$qs = Request::normalizeQueryString($this->requestStack->getCurrentRequest()->server->get('QUERY_STRING'));
return '' === $qs ? null : $qs;
} | [
"public",
"function",
"getQueryString",
"(",
")",
"{",
"$",
"qs",
"=",
"Request",
"::",
"normalizeQueryString",
"(",
"$",
"this",
"->",
"requestStack",
"->",
"getCurrentRequest",
"(",
")",
"->",
"server",
"->",
"get",
"(",
"'QUERY_STRING'",
")",
")",
";",
... | Get the query string parameters for the current request
Not used at present.
@return null|string | [
"Get",
"the",
"query",
"string",
"parameters",
"for",
"the",
"current",
"request",
"Not",
"used",
"at",
"present",
"."
] | 9c6e0f09de216e19795caac5840c197f46fde03d | https://github.com/networking/init-cms-bundle/blob/9c6e0f09de216e19795caac5840c197f46fde03d/src/Helper/LanguageSwitcherHelper.php#L203-L208 | train |
networking/init-cms-bundle | src/Helper/LanguageSwitcherHelper.php | LanguageSwitcherHelper.getPathInfo | public function getPathInfo($referrer = null)
{
$baseUrl = $this->prepareBaseUrl($referrer);
if (null === ($referrer)) {
return '/';
}
$pathInfo = '/';
// Remove the query string from REQUEST_URI
if ($pos = strpos($referrer, '?')) {
$referrer = substr($referrer, 0, $pos);
}
$host = $this->requestStack->getCurrentRequest()->getHost();
if ((null !== $baseUrl) && (false === ($pathInfo = substr($referrer, strlen($baseUrl))))) {
// If substr() returns false then PATH_INFO is set to an empty string
return '/';
} elseif (null === $baseUrl) {
return $referrer;
} elseif ($pos = strpos($pathInfo, $host)) {
$pathInfo = substr($pathInfo, $pos + strlen($host));
}
return (string) $pathInfo;
} | php | public function getPathInfo($referrer = null)
{
$baseUrl = $this->prepareBaseUrl($referrer);
if (null === ($referrer)) {
return '/';
}
$pathInfo = '/';
// Remove the query string from REQUEST_URI
if ($pos = strpos($referrer, '?')) {
$referrer = substr($referrer, 0, $pos);
}
$host = $this->requestStack->getCurrentRequest()->getHost();
if ((null !== $baseUrl) && (false === ($pathInfo = substr($referrer, strlen($baseUrl))))) {
// If substr() returns false then PATH_INFO is set to an empty string
return '/';
} elseif (null === $baseUrl) {
return $referrer;
} elseif ($pos = strpos($pathInfo, $host)) {
$pathInfo = substr($pathInfo, $pos + strlen($host));
}
return (string) $pathInfo;
} | [
"public",
"function",
"getPathInfo",
"(",
"$",
"referrer",
"=",
"null",
")",
"{",
"$",
"baseUrl",
"=",
"$",
"this",
"->",
"prepareBaseUrl",
"(",
"$",
"referrer",
")",
";",
"if",
"(",
"null",
"===",
"(",
"$",
"referrer",
")",
")",
"{",
"return",
"'/'"... | Returns the uri Path for the current uri if no referrer given,
otherwise it returns the path for the URL given.
@param null $referrer
@return null|string | [
"Returns",
"the",
"uri",
"Path",
"for",
"the",
"current",
"uri",
"if",
"no",
"referrer",
"given",
"otherwise",
"it",
"returns",
"the",
"path",
"for",
"the",
"URL",
"given",
"."
] | 9c6e0f09de216e19795caac5840c197f46fde03d | https://github.com/networking/init-cms-bundle/blob/9c6e0f09de216e19795caac5840c197f46fde03d/src/Helper/LanguageSwitcherHelper.php#L218-L244 | train |
networking/init-cms-bundle | src/Entity/MenuItemManager.php | MenuItemManager.findAllJoinPage | public function findAllJoinPage()
{
$qb = $this->createQueryBuilder('m');
$qb->select('m,p');
$qb->leftJoin('m.page', 'p');
return $qb->getQuery()->execute();
} | php | public function findAllJoinPage()
{
$qb = $this->createQueryBuilder('m');
$qb->select('m,p');
$qb->leftJoin('m.page', 'p');
return $qb->getQuery()->execute();
} | [
"public",
"function",
"findAllJoinPage",
"(",
")",
"{",
"$",
"qb",
"=",
"$",
"this",
"->",
"createQueryBuilder",
"(",
"'m'",
")",
";",
"$",
"qb",
"->",
"select",
"(",
"'m,p'",
")",
";",
"$",
"qb",
"->",
"leftJoin",
"(",
"'m.page'",
",",
"'p'",
")",
... | Get all menu items and their pages if available.
@return mixed | [
"Get",
"all",
"menu",
"items",
"and",
"their",
"pages",
"if",
"available",
"."
] | 9c6e0f09de216e19795caac5840c197f46fde03d | https://github.com/networking/init-cms-bundle/blob/9c6e0f09de216e19795caac5840c197f46fde03d/src/Entity/MenuItemManager.php#L145-L152 | train |
networking/init-cms-bundle | src/Controller/CacheController.php | CacheController.clearAction | public function clearAction()
{
/*
* to do: check if logged in user is sysadmin
* */
if ($this->authorizationChecker->isGranted('ROLE_SUPER_ADMIN')) {
/** @var \Networking\InitCmsBundle\Lib\PhpCacheInterface $phpCache */
$phpCache = $this->get('networking_init_cms.lib.php_cache');
$phpCache->clean();
/*clean function does not return status, therefore set success to true */
$success = true;
$response = ['success' => $success];
return new Response(json_encode($response));
} else {
/*wrong autorisation */
$success = false;
$response = ['success' => $success];
return new Response(json_encode($response));
}
} | php | public function clearAction()
{
/*
* to do: check if logged in user is sysadmin
* */
if ($this->authorizationChecker->isGranted('ROLE_SUPER_ADMIN')) {
/** @var \Networking\InitCmsBundle\Lib\PhpCacheInterface $phpCache */
$phpCache = $this->get('networking_init_cms.lib.php_cache');
$phpCache->clean();
/*clean function does not return status, therefore set success to true */
$success = true;
$response = ['success' => $success];
return new Response(json_encode($response));
} else {
/*wrong autorisation */
$success = false;
$response = ['success' => $success];
return new Response(json_encode($response));
}
} | [
"public",
"function",
"clearAction",
"(",
")",
"{",
"/*\n * to do: check if logged in user is sysadmin\n * */",
"if",
"(",
"$",
"this",
"->",
"authorizationChecker",
"->",
"isGranted",
"(",
"'ROLE_SUPER_ADMIN'",
")",
")",
"{",
"/** @var \\Networking\\InitCmsBu... | clear the Cache.
@return Response | [
"clear",
"the",
"Cache",
"."
] | 9c6e0f09de216e19795caac5840c197f46fde03d | https://github.com/networking/init-cms-bundle/blob/9c6e0f09de216e19795caac5840c197f46fde03d/src/Controller/CacheController.php#L45-L68 | train |
networking/init-cms-bundle | src/Controller/MenuItemAdminController.php | MenuItemAdminController.placementAction | public function placementAction()
{
/** @var \Networking\InitCmsBundle\Entity\MenuItem $rootNode */
$rootNode = $this->admin->getObject($this->get('session')->get('root_menu_id'));
if (!$rootNode) {
throw new NotFoundHttpException();
}
if ($rootNode->getChildren()->count() > 1) {
return $this->listAction(null, null, 'placement', $this->get('session')->get('root_menu_id'));
} else {
return false;
}
} | php | public function placementAction()
{
/** @var \Networking\InitCmsBundle\Entity\MenuItem $rootNode */
$rootNode = $this->admin->getObject($this->get('session')->get('root_menu_id'));
if (!$rootNode) {
throw new NotFoundHttpException();
}
if ($rootNode->getChildren()->count() > 1) {
return $this->listAction(null, null, 'placement', $this->get('session')->get('root_menu_id'));
} else {
return false;
}
} | [
"public",
"function",
"placementAction",
"(",
")",
"{",
"/** @var \\Networking\\InitCmsBundle\\Entity\\MenuItem $rootNode */",
"$",
"rootNode",
"=",
"$",
"this",
"->",
"admin",
"->",
"getObject",
"(",
"$",
"this",
"->",
"get",
"(",
"'session'",
")",
"->",
"get",
"... | renders the template html for the modal.
@return bool|string|Response
@throws \Sonata\AdminBundle\Exception\NoValueException | [
"renders",
"the",
"template",
"html",
"for",
"the",
"modal",
"."
] | 9c6e0f09de216e19795caac5840c197f46fde03d | https://github.com/networking/init-cms-bundle/blob/9c6e0f09de216e19795caac5840c197f46fde03d/src/Controller/MenuItemAdminController.php#L490-L504 | train |
networking/init-cms-bundle | src/EventListener/UserActivityListener.php | UserActivityListener.onCoreController | public function onCoreController(FilterControllerEvent $event)
{
// do not capture admin cms urls
if (!preg_match('/.*\/admin\/.*/', $event->getRequest()->getRequestUri())) {
return;
}
if (!$this->tokenStorage->getToken()) {
return;
}
$user = $this->tokenStorage->getToken()->getUser();
if ($user instanceof UserInterface) {
//here we can update the user as necessary
if (method_exists($user, 'setLastActivity')) {
try {
$user->setLastActivity(new \DateTime('now'));
$this->em->persist($user);
$this->em->flush($user);
} catch (\Doctrine\ORM\ORMException $e) {
//do nothing, entity manager is closed
}
}
}
} | php | public function onCoreController(FilterControllerEvent $event)
{
// do not capture admin cms urls
if (!preg_match('/.*\/admin\/.*/', $event->getRequest()->getRequestUri())) {
return;
}
if (!$this->tokenStorage->getToken()) {
return;
}
$user = $this->tokenStorage->getToken()->getUser();
if ($user instanceof UserInterface) {
//here we can update the user as necessary
if (method_exists($user, 'setLastActivity')) {
try {
$user->setLastActivity(new \DateTime('now'));
$this->em->persist($user);
$this->em->flush($user);
} catch (\Doctrine\ORM\ORMException $e) {
//do nothing, entity manager is closed
}
}
}
} | [
"public",
"function",
"onCoreController",
"(",
"FilterControllerEvent",
"$",
"event",
")",
"{",
"// do not capture admin cms urls",
"if",
"(",
"!",
"preg_match",
"(",
"'/.*\\/admin\\/.*/'",
",",
"$",
"event",
"->",
"getRequest",
"(",
")",
"->",
"getRequestUri",
"(",... | On each request we want to update the user's last activity datetime.
@param \Symfony\Component\HttpKernel\Event\FilterControllerEvent $event | [
"On",
"each",
"request",
"we",
"want",
"to",
"update",
"the",
"user",
"s",
"last",
"activity",
"datetime",
"."
] | 9c6e0f09de216e19795caac5840c197f46fde03d | https://github.com/networking/init-cms-bundle/blob/9c6e0f09de216e19795caac5840c197f46fde03d/src/EventListener/UserActivityListener.php#L53-L78 | train |
networking/init-cms-bundle | src/Menu/MenuBuilder.php | MenuBuilder.getParentMenu | public function getParentMenu(Menu $menu, MenuItem $childNode)
{
$itemIterator = new RecursiveItemIterator($menu->getIterator());
$iterator = new \RecursiveIteratorIterator($itemIterator, \RecursiveIteratorIterator::SELF_FIRST);
foreach ($iterator as $menuItem) {
$parentId = $childNode->getParent()->getId();
if ($menuItem->getName() != $parentId) {
continue;
}
return $menuItem;
}
return false;
} | php | public function getParentMenu(Menu $menu, MenuItem $childNode)
{
$itemIterator = new RecursiveItemIterator($menu->getIterator());
$iterator = new \RecursiveIteratorIterator($itemIterator, \RecursiveIteratorIterator::SELF_FIRST);
foreach ($iterator as $menuItem) {
$parentId = $childNode->getParent()->getId();
if ($menuItem->getName() != $parentId) {
continue;
}
return $menuItem;
}
return false;
} | [
"public",
"function",
"getParentMenu",
"(",
"Menu",
"$",
"menu",
",",
"MenuItem",
"$",
"childNode",
")",
"{",
"$",
"itemIterator",
"=",
"new",
"RecursiveItemIterator",
"(",
"$",
"menu",
"->",
"getIterator",
"(",
")",
")",
";",
"$",
"iterator",
"=",
"new",
... | Recursively get parents.
@param $menu - menu to look for the parent in
@param $childNode - menu node whose parent we are looking for
@return mixed | [
"Recursively",
"get",
"parents",
"."
] | 9c6e0f09de216e19795caac5840c197f46fde03d | https://github.com/networking/init-cms-bundle/blob/9c6e0f09de216e19795caac5840c197f46fde03d/src/Menu/MenuBuilder.php#L210-L224 | train |
networking/init-cms-bundle | src/Menu/MenuBuilder.php | MenuBuilder.createFromMenuItem | public function createFromMenuItem(MenuItem $menuItem)
{
if ($path = $menuItem->getPath()) {
$uri = $this->request->getBaseUrl().$path;
} elseif ($menuItem->getRedirectUrl()) {
$uri = $menuItem->getRedirectUrl();
} elseif ($menuItem->getInternalUrl()) {
$uri = $this->request->getBaseUrl().$menuItem->getInternalUrl();
} elseif ($contentRoute = $menuItem->getContentRoute()) {
$route = ContentRouteManager::generateRoute($contentRoute, $contentRoute->getPath(), '');
$uri = $this->request->getBaseUrl().$route->getPath();
} else {
$uri = '#';
}
$options = [
'uri' => $uri,
'label' => $menuItem->getName(),
'attributes' => [],
'linkAttributes' => $menuItem->getLinkAttributes(),
'childrenAttributes' => [],
'labelAttributes' => [],
'extras' => [],
'display' => true,
'displayChildren' => true,
];
$item = $this->factory->createItem($menuItem->getId(), $options);
if ($menuItem->isHidden()) {
$item->setDisplay(false);
}
return $item;
} | php | public function createFromMenuItem(MenuItem $menuItem)
{
if ($path = $menuItem->getPath()) {
$uri = $this->request->getBaseUrl().$path;
} elseif ($menuItem->getRedirectUrl()) {
$uri = $menuItem->getRedirectUrl();
} elseif ($menuItem->getInternalUrl()) {
$uri = $this->request->getBaseUrl().$menuItem->getInternalUrl();
} elseif ($contentRoute = $menuItem->getContentRoute()) {
$route = ContentRouteManager::generateRoute($contentRoute, $contentRoute->getPath(), '');
$uri = $this->request->getBaseUrl().$route->getPath();
} else {
$uri = '#';
}
$options = [
'uri' => $uri,
'label' => $menuItem->getName(),
'attributes' => [],
'linkAttributes' => $menuItem->getLinkAttributes(),
'childrenAttributes' => [],
'labelAttributes' => [],
'extras' => [],
'display' => true,
'displayChildren' => true,
];
$item = $this->factory->createItem($menuItem->getId(), $options);
if ($menuItem->isHidden()) {
$item->setDisplay(false);
}
return $item;
} | [
"public",
"function",
"createFromMenuItem",
"(",
"MenuItem",
"$",
"menuItem",
")",
"{",
"if",
"(",
"$",
"path",
"=",
"$",
"menuItem",
"->",
"getPath",
"(",
")",
")",
"{",
"$",
"uri",
"=",
"$",
"this",
"->",
"request",
"->",
"getBaseUrl",
"(",
")",
".... | Create an new node using the ContentRoute object to generate the uri.
@param \Networking\InitCmsBundle\Entity\MenuItem $menuItem
@return \Knp\Menu\ItemInterface | [
"Create",
"an",
"new",
"node",
"using",
"the",
"ContentRoute",
"object",
"to",
"generate",
"the",
"uri",
"."
] | 9c6e0f09de216e19795caac5840c197f46fde03d | https://github.com/networking/init-cms-bundle/blob/9c6e0f09de216e19795caac5840c197f46fde03d/src/Menu/MenuBuilder.php#L233-L267 | train |
networking/init-cms-bundle | src/Menu/MenuBuilder.php | MenuBuilder.getFullMenu | public function getFullMenu($menuName)
{
if (is_array($menuName)) {
$menuName = reset($menuName);
}
if (array_key_exists($menuName, $this->menuIterators) && count($this->menuIterators[$menuName]) > 0) {
return $this->menuIterators[$menuName];
}
/** @var $mainMenu Menu */
$mainMenu = $this->menuManager->findOneBy(
['name' => $menuName, 'locale' => $this->request->getLocale()]
);
if (!$mainMenu) {
return [];
}
$this->menuIterators[$menuName] = $this->menuManager->getChildrenByStatus(
$mainMenu,
false,
null,
'ASC',
false,
$this->viewStatus
);
return $this->menuIterators[$menuName];
} | php | public function getFullMenu($menuName)
{
if (is_array($menuName)) {
$menuName = reset($menuName);
}
if (array_key_exists($menuName, $this->menuIterators) && count($this->menuIterators[$menuName]) > 0) {
return $this->menuIterators[$menuName];
}
/** @var $mainMenu Menu */
$mainMenu = $this->menuManager->findOneBy(
['name' => $menuName, 'locale' => $this->request->getLocale()]
);
if (!$mainMenu) {
return [];
}
$this->menuIterators[$menuName] = $this->menuManager->getChildrenByStatus(
$mainMenu,
false,
null,
'ASC',
false,
$this->viewStatus
);
return $this->menuIterators[$menuName];
} | [
"public",
"function",
"getFullMenu",
"(",
"$",
"menuName",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"menuName",
")",
")",
"{",
"$",
"menuName",
"=",
"reset",
"(",
"$",
"menuName",
")",
";",
"}",
"if",
"(",
"array_key_exists",
"(",
"$",
"menuName",
... | Retrieve the full menu tree.
@param string $menuName
@return array|bool | [
"Retrieve",
"the",
"full",
"menu",
"tree",
"."
] | 9c6e0f09de216e19795caac5840c197f46fde03d | https://github.com/networking/init-cms-bundle/blob/9c6e0f09de216e19795caac5840c197f46fde03d/src/Menu/MenuBuilder.php#L276-L305 | train |
networking/init-cms-bundle | src/Menu/MenuBuilder.php | MenuBuilder.getSubMenu | public function getSubMenu($menuName, $level = 1)
{
$currentParent = false;
$mainMenuIterator = $this->getFullMenu($menuName);
if (!$mainMenuIterator) {
return false;
}
foreach ($mainMenuIterator as $menuItem) {
if ($this->currentPath === $menuItem->getPath()
|| $this->currentPath === $menuItem->getInternalUrl()
) {
$currentParent = $menuItem->getParentByLevel($level);
}
}
if (!$currentParent) {
return false;
}
$menuIterator = $this->menuManager->getChildrenByStatus(
$currentParent,
false,
null,
'ASC',
false,
$this->viewStatus
);
return $menuIterator;
} | php | public function getSubMenu($menuName, $level = 1)
{
$currentParent = false;
$mainMenuIterator = $this->getFullMenu($menuName);
if (!$mainMenuIterator) {
return false;
}
foreach ($mainMenuIterator as $menuItem) {
if ($this->currentPath === $menuItem->getPath()
|| $this->currentPath === $menuItem->getInternalUrl()
) {
$currentParent = $menuItem->getParentByLevel($level);
}
}
if (!$currentParent) {
return false;
}
$menuIterator = $this->menuManager->getChildrenByStatus(
$currentParent,
false,
null,
'ASC',
false,
$this->viewStatus
);
return $menuIterator;
} | [
"public",
"function",
"getSubMenu",
"(",
"$",
"menuName",
",",
"$",
"level",
"=",
"1",
")",
"{",
"$",
"currentParent",
"=",
"false",
";",
"$",
"mainMenuIterator",
"=",
"$",
"this",
"->",
"getFullMenu",
"(",
"$",
"menuName",
")",
";",
"if",
"(",
"!",
... | Retrieves the sub menu array based on the current url.
@param string $menuName
@param int $level
@return array|bool | [
"Retrieves",
"the",
"sub",
"menu",
"array",
"based",
"on",
"the",
"current",
"url",
"."
] | 9c6e0f09de216e19795caac5840c197f46fde03d | https://github.com/networking/init-cms-bundle/blob/9c6e0f09de216e19795caac5840c197f46fde03d/src/Menu/MenuBuilder.php#L315-L347 | train |
networking/init-cms-bundle | src/Menu/MenuBuilder.php | MenuBuilder.createMenu | public function createMenu(Menu $menu, $menuIterator, $startDepth)
{
foreach ($menuIterator as $childNode) {
$this->addNodeToMenu($menu, $childNode, $startDepth);
}
return $menu;
} | php | public function createMenu(Menu $menu, $menuIterator, $startDepth)
{
foreach ($menuIterator as $childNode) {
$this->addNodeToMenu($menu, $childNode, $startDepth);
}
return $menu;
} | [
"public",
"function",
"createMenu",
"(",
"Menu",
"$",
"menu",
",",
"$",
"menuIterator",
",",
"$",
"startDepth",
")",
"{",
"foreach",
"(",
"$",
"menuIterator",
"as",
"$",
"childNode",
")",
"{",
"$",
"this",
"->",
"addNodeToMenu",
"(",
"$",
"menu",
",",
... | Creates a full menu based on the starting point given.
@param Menu $menu
@param array $menuIterator
@param int $startDepth
@return Menu | [
"Creates",
"a",
"full",
"menu",
"based",
"on",
"the",
"starting",
"point",
"given",
"."
] | 9c6e0f09de216e19795caac5840c197f46fde03d | https://github.com/networking/init-cms-bundle/blob/9c6e0f09de216e19795caac5840c197f46fde03d/src/Menu/MenuBuilder.php#L358-L365 | train |
networking/init-cms-bundle | src/Menu/MenuBuilder.php | MenuBuilder.addNodeToMenu | public function addNodeToMenu(Menu $menu, MenuItem $node, $startDepth)
{
if ($node->getLvl() < $startDepth) {
return false;
}
if ($node->getLvl() > $startDepth) {
$menu = $this->getParentMenu($menu, $node);
}
if (is_object($menu)) {
$knpMenuNode = $this->createFromMenuItem($node);
if (!is_null($knpMenuNode)) {
$menu->addChild($knpMenuNode);
$knpMenuNode->setAttribute('class', $node->getLinkClass());
$knpMenuNode->setExtra('translation_domain', false);
if ($node->getVisibility() != MenuItem::VISIBILITY_PUBLIC && !$this->isLoggedIn) {
$knpMenuNode->setDisplay(false);
}
return $knpMenuNode;
}
}
return false;
} | php | public function addNodeToMenu(Menu $menu, MenuItem $node, $startDepth)
{
if ($node->getLvl() < $startDepth) {
return false;
}
if ($node->getLvl() > $startDepth) {
$menu = $this->getParentMenu($menu, $node);
}
if (is_object($menu)) {
$knpMenuNode = $this->createFromMenuItem($node);
if (!is_null($knpMenuNode)) {
$menu->addChild($knpMenuNode);
$knpMenuNode->setAttribute('class', $node->getLinkClass());
$knpMenuNode->setExtra('translation_domain', false);
if ($node->getVisibility() != MenuItem::VISIBILITY_PUBLIC && !$this->isLoggedIn) {
$knpMenuNode->setDisplay(false);
}
return $knpMenuNode;
}
}
return false;
} | [
"public",
"function",
"addNodeToMenu",
"(",
"Menu",
"$",
"menu",
",",
"MenuItem",
"$",
"node",
",",
"$",
"startDepth",
")",
"{",
"if",
"(",
"$",
"node",
"->",
"getLvl",
"(",
")",
"<",
"$",
"startDepth",
")",
"{",
"return",
"false",
";",
"}",
"if",
... | Add a menu item node at the correct place in the menu.
@param Menu $menu
@param MenuItem $node
@param $startDepth
@return bool|\Knp\Menu\ItemInterface | [
"Add",
"a",
"menu",
"item",
"node",
"at",
"the",
"correct",
"place",
"in",
"the",
"menu",
"."
] | 9c6e0f09de216e19795caac5840c197f46fde03d | https://github.com/networking/init-cms-bundle/blob/9c6e0f09de216e19795caac5840c197f46fde03d/src/Menu/MenuBuilder.php#L376-L401 | train |
networking/init-cms-bundle | src/Menu/MenuBuilder.php | MenuBuilder.showOnlyCurrentChildren | public function showOnlyCurrentChildren(ItemInterface $menu)
{
$itemIterator = new RecursiveItemIterator($menu->getIterator());
$iterator = new \RecursiveIteratorIterator($itemIterator, \RecursiveIteratorIterator::SELF_FIRST);
foreach ($iterator as $menuItem) {
/** @var \Knp\Menu\MenuItem $menuItem */
if (!$this->matcher->isCurrent($menuItem) && !$this->matcher->isAncestor($menuItem)) {
$menuItem->setDisplayChildren(false);
}
}
} | php | public function showOnlyCurrentChildren(ItemInterface $menu)
{
$itemIterator = new RecursiveItemIterator($menu->getIterator());
$iterator = new \RecursiveIteratorIterator($itemIterator, \RecursiveIteratorIterator::SELF_FIRST);
foreach ($iterator as $menuItem) {
/** @var \Knp\Menu\MenuItem $menuItem */
if (!$this->matcher->isCurrent($menuItem) && !$this->matcher->isAncestor($menuItem)) {
$menuItem->setDisplayChildren(false);
}
}
} | [
"public",
"function",
"showOnlyCurrentChildren",
"(",
"ItemInterface",
"$",
"menu",
")",
"{",
"$",
"itemIterator",
"=",
"new",
"RecursiveItemIterator",
"(",
"$",
"menu",
"->",
"getIterator",
"(",
")",
")",
";",
"$",
"iterator",
"=",
"new",
"\\",
"RecursiveIter... | Set the children menu item nodes to be shown only if the node
is current or the parent is a current ancestor.
@param ItemInterface $menu | [
"Set",
"the",
"children",
"menu",
"item",
"nodes",
"to",
"be",
"shown",
"only",
"if",
"the",
"node",
"is",
"current",
"or",
"the",
"parent",
"is",
"a",
"current",
"ancestor",
"."
] | 9c6e0f09de216e19795caac5840c197f46fde03d | https://github.com/networking/init-cms-bundle/blob/9c6e0f09de216e19795caac5840c197f46fde03d/src/Menu/MenuBuilder.php#L409-L420 | train |
networking/init-cms-bundle | src/Menu/MenuBuilder.php | MenuBuilder.setRecursiveAttribute | public function setRecursiveAttribute(ItemInterface $menu, array $attr)
{
$itemIterator = new RecursiveItemIterator($menu->getIterator());
$iterator = new \RecursiveIteratorIterator($itemIterator, \RecursiveIteratorIterator::SELF_FIRST);
foreach ($iterator as $menuItem) {
/* @var ItemInterface $menuItem */
$menuItem->setChildrenAttributes($attr);
}
} | php | public function setRecursiveAttribute(ItemInterface $menu, array $attr)
{
$itemIterator = new RecursiveItemIterator($menu->getIterator());
$iterator = new \RecursiveIteratorIterator($itemIterator, \RecursiveIteratorIterator::SELF_FIRST);
foreach ($iterator as $menuItem) {
/* @var ItemInterface $menuItem */
$menuItem->setChildrenAttributes($attr);
}
} | [
"public",
"function",
"setRecursiveAttribute",
"(",
"ItemInterface",
"$",
"menu",
",",
"array",
"$",
"attr",
")",
"{",
"$",
"itemIterator",
"=",
"new",
"RecursiveItemIterator",
"(",
"$",
"menu",
"->",
"getIterator",
"(",
")",
")",
";",
"$",
"iterator",
"=",
... | Recursively set attributes on an item and its' children.
@param ItemInterface $menu
@param array $attr | [
"Recursively",
"set",
"attributes",
"on",
"an",
"item",
"and",
"its",
"children",
"."
] | 9c6e0f09de216e19795caac5840c197f46fde03d | https://github.com/networking/init-cms-bundle/blob/9c6e0f09de216e19795caac5840c197f46fde03d/src/Menu/MenuBuilder.php#L442-L451 | train |
networking/init-cms-bundle | src/Twig/Extension/NetworkingHelperExtension.php | NetworkingHelperExtension.renderInitCmsBlock | public function renderInitCmsBlock($template, LayoutBlockInterface $layoutBlock, $params = [])
{
if (!$serializedContent = $layoutBlock->getSnapshotContent()) {
// Draft View
$contentItem = $layoutBlock->getContent();
} else {
// Live View
$contentItem = $this->serializer->deserialize(
$serializedContent,
$layoutBlock->getClassType(),
'json'
);
}
if (!is_object($contentItem)) {
$this->layoutBlockAdmin->delete($layoutBlock);
return '---';
}
$options = $contentItem->getTemplateOptions($params);
$options = array_merge($options, $params);
return $this->templating->render($template, $options);
} | php | public function renderInitCmsBlock($template, LayoutBlockInterface $layoutBlock, $params = [])
{
if (!$serializedContent = $layoutBlock->getSnapshotContent()) {
// Draft View
$contentItem = $layoutBlock->getContent();
} else {
// Live View
$contentItem = $this->serializer->deserialize(
$serializedContent,
$layoutBlock->getClassType(),
'json'
);
}
if (!is_object($contentItem)) {
$this->layoutBlockAdmin->delete($layoutBlock);
return '---';
}
$options = $contentItem->getTemplateOptions($params);
$options = array_merge($options, $params);
return $this->templating->render($template, $options);
} | [
"public",
"function",
"renderInitCmsBlock",
"(",
"$",
"template",
",",
"LayoutBlockInterface",
"$",
"layoutBlock",
",",
"$",
"params",
"=",
"[",
"]",
")",
"{",
"if",
"(",
"!",
"$",
"serializedContent",
"=",
"$",
"layoutBlock",
"->",
"getSnapshotContent",
"(",
... | Returns an HTML block for output in the frontend.
@param $template
@param LayoutBlockInterface $layoutBlock
@param array $params
@return string | [
"Returns",
"an",
"HTML",
"block",
"for",
"output",
"in",
"the",
"frontend",
"."
] | 9c6e0f09de216e19795caac5840c197f46fde03d | https://github.com/networking/init-cms-bundle/blob/9c6e0f09de216e19795caac5840c197f46fde03d/src/Twig/Extension/NetworkingHelperExtension.php#L244-L269 | train |
networking/init-cms-bundle | src/Twig/Extension/NetworkingHelperExtension.php | NetworkingHelperExtension.renderInitcmsAdminBlock | public function renderInitcmsAdminBlock(LayoutBlockInterface $layoutBlock)
{
if ($layoutBlock->getObjectId()) {
// Draft View
$contentItem = $layoutBlock->getContent();
} else {
$classType = $layoutBlock->getClassType();
$contentItem = new $classType();
}
if (!is_object($contentItem)) {
$this->layoutBlockAdmin->delete($layoutBlock);
return false;
}
$adminContent = $contentItem->getAdminContent();
return $this->templating->render($adminContent['template'], $adminContent['content']);
} | php | public function renderInitcmsAdminBlock(LayoutBlockInterface $layoutBlock)
{
if ($layoutBlock->getObjectId()) {
// Draft View
$contentItem = $layoutBlock->getContent();
} else {
$classType = $layoutBlock->getClassType();
$contentItem = new $classType();
}
if (!is_object($contentItem)) {
$this->layoutBlockAdmin->delete($layoutBlock);
return false;
}
$adminContent = $contentItem->getAdminContent();
return $this->templating->render($adminContent['template'], $adminContent['content']);
} | [
"public",
"function",
"renderInitcmsAdminBlock",
"(",
"LayoutBlockInterface",
"$",
"layoutBlock",
")",
"{",
"if",
"(",
"$",
"layoutBlock",
"->",
"getObjectId",
"(",
")",
")",
"{",
"// Draft View",
"$",
"contentItem",
"=",
"$",
"layoutBlock",
"->",
"getContent",
... | Returns an HTML block for output in the admin area.
@param LayoutBlockInterface $layoutBlock
@return bool|string | [
"Returns",
"an",
"HTML",
"block",
"for",
"output",
"in",
"the",
"admin",
"area",
"."
] | 9c6e0f09de216e19795caac5840c197f46fde03d | https://github.com/networking/init-cms-bundle/blob/9c6e0f09de216e19795caac5840c197f46fde03d/src/Twig/Extension/NetworkingHelperExtension.php#L278-L297 | train |
networking/init-cms-bundle | src/Twig/Extension/NetworkingHelperExtension.php | NetworkingHelperExtension.getInitcmsAdminIconPath | public function getInitcmsAdminIconPath(
AdminInterface $admin,
$size = 'small',
$active = false
) {
$state = $active ? '_active' : '';
$imagePath = '/bundles/networkinginitcms/img/icons/icon_blank_'.$size.$state.'.png';
$bundleGuesser = new BundleGuesser();
$bundleGuesser->initialize($admin);
$bundleName = $bundleGuesser->getBundleShortName();
$bundles = $this->kernel->getBundle($bundleName, false);
$bundle = end($bundles);
$path = $bundle->getPath();
$slug = self::slugify($admin->getLabel());
$iconName = 'icon_'.$slug.'_'.$size.$state;
$folders = ['img/icons', 'image/icons', 'img', 'image'];
$imageType = ['gif', 'png', 'jpg', 'jpeg'];
foreach ($folders as $folder) {
foreach ($imageType as $type) {
$icon = $folder.DIRECTORY_SEPARATOR.$iconName.'.'.$type;
if (file_exists(
$path.DIRECTORY_SEPARATOR.'Resources'.DIRECTORY_SEPARATOR.'public'.DIRECTORY_SEPARATOR.$icon
)
) {
$imagePath = 'bundles'.DIRECTORY_SEPARATOR.str_replace(
'bundle',
'',
strtolower($bundleName)
).DIRECTORY_SEPARATOR.$icon;
}
}
}
return $imagePath;
} | php | public function getInitcmsAdminIconPath(
AdminInterface $admin,
$size = 'small',
$active = false
) {
$state = $active ? '_active' : '';
$imagePath = '/bundles/networkinginitcms/img/icons/icon_blank_'.$size.$state.'.png';
$bundleGuesser = new BundleGuesser();
$bundleGuesser->initialize($admin);
$bundleName = $bundleGuesser->getBundleShortName();
$bundles = $this->kernel->getBundle($bundleName, false);
$bundle = end($bundles);
$path = $bundle->getPath();
$slug = self::slugify($admin->getLabel());
$iconName = 'icon_'.$slug.'_'.$size.$state;
$folders = ['img/icons', 'image/icons', 'img', 'image'];
$imageType = ['gif', 'png', 'jpg', 'jpeg'];
foreach ($folders as $folder) {
foreach ($imageType as $type) {
$icon = $folder.DIRECTORY_SEPARATOR.$iconName.'.'.$type;
if (file_exists(
$path.DIRECTORY_SEPARATOR.'Resources'.DIRECTORY_SEPARATOR.'public'.DIRECTORY_SEPARATOR.$icon
)
) {
$imagePath = 'bundles'.DIRECTORY_SEPARATOR.str_replace(
'bundle',
'',
strtolower($bundleName)
).DIRECTORY_SEPARATOR.$icon;
}
}
}
return $imagePath;
} | [
"public",
"function",
"getInitcmsAdminIconPath",
"(",
"AdminInterface",
"$",
"admin",
",",
"$",
"size",
"=",
"'small'",
",",
"$",
"active",
"=",
"false",
")",
"{",
"$",
"state",
"=",
"$",
"active",
"?",
"'_active'",
":",
"''",
";",
"$",
"imagePath",
"=",... | Guess which icon should represent an entity admin.
@param AdminInterface $admin
@param string $size
@param bool $active
@return string
@todo This is a bit of a hack. Need to provide a better way of providing admin icons | [
"Guess",
"which",
"icon",
"should",
"represent",
"an",
"entity",
"admin",
"."
] | 9c6e0f09de216e19795caac5840c197f46fde03d | https://github.com/networking/init-cms-bundle/blob/9c6e0f09de216e19795caac5840c197f46fde03d/src/Twig/Extension/NetworkingHelperExtension.php#L476-L517 | train |
networking/init-cms-bundle | src/Twig/Extension/NetworkingHelperExtension.php | NetworkingHelperExtension.getCurrentAdminLocale | public function getCurrentAdminLocale(\Sonata\AdminBundle\Admin\AdminInterface $admin)
{
$locale = '';
if (!$admin->hasRequest()) {
$admin->setRequest($this->requestStack->getCurrentRequest());
}
if ($subject = $admin->getSubject()) {
return $this->getFieldValue($subject, 'locale');
} elseif ($filter = $admin->getDatagrid()->getFilter('locale')) {
/** @var \Sonata\AdminBundle\Filter\Filter $filter */
$data = $filter->getValue();
if (!$data || !is_array($data) || !array_key_exists('value', $data)) {
$locale = $this->getCurrentLocale();
}
$data['value'] = trim($data['value']);
if (strlen($data['value']) > 0) {
$locale = $data['value'];
}
if (!$locale && method_exists($admin, 'getDefaultLocale')) {
$locale = $admin->getDefaultLocale();
}
}
return $locale;
} | php | public function getCurrentAdminLocale(\Sonata\AdminBundle\Admin\AdminInterface $admin)
{
$locale = '';
if (!$admin->hasRequest()) {
$admin->setRequest($this->requestStack->getCurrentRequest());
}
if ($subject = $admin->getSubject()) {
return $this->getFieldValue($subject, 'locale');
} elseif ($filter = $admin->getDatagrid()->getFilter('locale')) {
/** @var \Sonata\AdminBundle\Filter\Filter $filter */
$data = $filter->getValue();
if (!$data || !is_array($data) || !array_key_exists('value', $data)) {
$locale = $this->getCurrentLocale();
}
$data['value'] = trim($data['value']);
if (strlen($data['value']) > 0) {
$locale = $data['value'];
}
if (!$locale && method_exists($admin, 'getDefaultLocale')) {
$locale = $admin->getDefaultLocale();
}
}
return $locale;
} | [
"public",
"function",
"getCurrentAdminLocale",
"(",
"\\",
"Sonata",
"\\",
"AdminBundle",
"\\",
"Admin",
"\\",
"AdminInterface",
"$",
"admin",
")",
"{",
"$",
"locale",
"=",
"''",
";",
"if",
"(",
"!",
"$",
"admin",
"->",
"hasRequest",
"(",
")",
")",
"{",
... | returns the locale of the current admin user.
@param AdminInterface $admin
@return mixed|string | [
"returns",
"the",
"locale",
"of",
"the",
"current",
"admin",
"user",
"."
] | 9c6e0f09de216e19795caac5840c197f46fde03d | https://github.com/networking/init-cms-bundle/blob/9c6e0f09de216e19795caac5840c197f46fde03d/src/Twig/Extension/NetworkingHelperExtension.php#L559-L588 | train |
networking/init-cms-bundle | src/Twig/Extension/NetworkingHelperExtension.php | NetworkingHelperExtension.getSubFormsByZone | public function getSubFormsByZone($formChildren, $zone)
{
$zones = [];
foreach ($formChildren as $subForms) {
if ($this->getFormFieldZone($subForms) == $zone) {
$zones[] = $subForms;
}
}
return $zones;
} | php | public function getSubFormsByZone($formChildren, $zone)
{
$zones = [];
foreach ($formChildren as $subForms) {
if ($this->getFormFieldZone($subForms) == $zone) {
$zones[] = $subForms;
}
}
return $zones;
} | [
"public",
"function",
"getSubFormsByZone",
"(",
"$",
"formChildren",
",",
"$",
"zone",
")",
"{",
"$",
"zones",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"formChildren",
"as",
"$",
"subForms",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"getFormFieldZone",
"... | Gets a list of forms sorted to a particular zone.
@param $formChildren
@param $zone
@return array | [
"Gets",
"a",
"list",
"of",
"forms",
"sorted",
"to",
"a",
"particular",
"zone",
"."
] | 9c6e0f09de216e19795caac5840c197f46fde03d | https://github.com/networking/init-cms-bundle/blob/9c6e0f09de216e19795caac5840c197f46fde03d/src/Twig/Extension/NetworkingHelperExtension.php#L702-L713 | train |
networking/init-cms-bundle | src/Twig/Extension/NetworkingHelperExtension.php | NetworkingHelperExtension.getContentCss | public function getContentCss($configName = null)
{
if (is_null($configName)) {
$configName = $this->ckEditorConfigManager->getDefaultConfig();
}
$configs = $this->ckEditorConfigManager->getConfigs();
if (array_key_exists('contentsCss', $configs[$configName])) {
return $configs[$configName]['contentsCss'];
}
return false;
} | php | public function getContentCss($configName = null)
{
if (is_null($configName)) {
$configName = $this->ckEditorConfigManager->getDefaultConfig();
}
$configs = $this->ckEditorConfigManager->getConfigs();
if (array_key_exists('contentsCss', $configs[$configName])) {
return $configs[$configName]['contentsCss'];
}
return false;
} | [
"public",
"function",
"getContentCss",
"(",
"$",
"configName",
"=",
"null",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"configName",
")",
")",
"{",
"$",
"configName",
"=",
"$",
"this",
"->",
"ckEditorConfigManager",
"->",
"getDefaultConfig",
"(",
")",
";",
... | Return the path to the content css for the default or named ckeditor config contentsCss.
@param null $configName
@return bool | [
"Return",
"the",
"path",
"to",
"the",
"content",
"css",
"for",
"the",
"default",
"or",
"named",
"ckeditor",
"config",
"contentsCss",
"."
] | 9c6e0f09de216e19795caac5840c197f46fde03d | https://github.com/networking/init-cms-bundle/blob/9c6e0f09de216e19795caac5840c197f46fde03d/src/Twig/Extension/NetworkingHelperExtension.php#L1191-L1203 | train |
networking/init-cms-bundle | src/Twig/Extension/NetworkingHelperExtension.php | NetworkingHelperExtension.getFileIcon | public function getFileIcon($filename)
{
$parts = explode('.', $filename);
$postfix = strtolower(end($parts));
switch ($postfix) {
case 'doc':
case 'docx':
$icon = 'far fa-file-word';
break;
case 'pdf':
$icon = 'far fa-file-pdf';
break;
case 'xls':
case 'xlsx':
$icon = 'far fa-file-excel';
break;
case 'ppt':
case 'pptx':
$icon = 'far fa-file-powerpoint';
break;
case 'zip':
$icon = 'far fa-file-archive';
break;
case 'txt':
case 'rtf':
$icon = 'far fa-file-alt';
break;
case 'png':
case 'gif':
case 'jpeg':
case 'jpg':
case 'svg':
$icon = 'far fa-file-image';
break;
default:
$icon = 'far fa-file';
break;
}
return 'fa '.$icon;
} | php | public function getFileIcon($filename)
{
$parts = explode('.', $filename);
$postfix = strtolower(end($parts));
switch ($postfix) {
case 'doc':
case 'docx':
$icon = 'far fa-file-word';
break;
case 'pdf':
$icon = 'far fa-file-pdf';
break;
case 'xls':
case 'xlsx':
$icon = 'far fa-file-excel';
break;
case 'ppt':
case 'pptx':
$icon = 'far fa-file-powerpoint';
break;
case 'zip':
$icon = 'far fa-file-archive';
break;
case 'txt':
case 'rtf':
$icon = 'far fa-file-alt';
break;
case 'png':
case 'gif':
case 'jpeg':
case 'jpg':
case 'svg':
$icon = 'far fa-file-image';
break;
default:
$icon = 'far fa-file';
break;
}
return 'fa '.$icon;
} | [
"public",
"function",
"getFileIcon",
"(",
"$",
"filename",
")",
"{",
"$",
"parts",
"=",
"explode",
"(",
"'.'",
",",
"$",
"filename",
")",
";",
"$",
"postfix",
"=",
"strtolower",
"(",
"end",
"(",
"$",
"parts",
")",
")",
";",
"switch",
"(",
"$",
"pos... | Guess which fontawesome icon to use.
@param $filename
@return string | [
"Guess",
"which",
"fontawesome",
"icon",
"to",
"use",
"."
] | 9c6e0f09de216e19795caac5840c197f46fde03d | https://github.com/networking/init-cms-bundle/blob/9c6e0f09de216e19795caac5840c197f46fde03d/src/Twig/Extension/NetworkingHelperExtension.php#L1212-L1253 | train |
networking/init-cms-bundle | src/Helper/PageHelper.php | PageHelper.setFieldValue | public static function setFieldValue(PageInterface $object, $fieldName, $value, $method = null)
{
$setters = [];
// prefer method name given in the code option
if ($method) {
$setters[] = $method;
}
$camelizedFieldName = self::camelize($fieldName);
$setters[] = 'set'.$camelizedFieldName;
foreach ($setters as $setter) {
if (method_exists($object, $setter)) {
call_user_func([&$object, $setter], $value);
return $object;
}
}
if ($object->getId()) {
throw new NoValueException(sprintf('Unable to set the value of `%s`', $camelizedFieldName));
}
return $object;
} | php | public static function setFieldValue(PageInterface $object, $fieldName, $value, $method = null)
{
$setters = [];
// prefer method name given in the code option
if ($method) {
$setters[] = $method;
}
$camelizedFieldName = self::camelize($fieldName);
$setters[] = 'set'.$camelizedFieldName;
foreach ($setters as $setter) {
if (method_exists($object, $setter)) {
call_user_func([&$object, $setter], $value);
return $object;
}
}
if ($object->getId()) {
throw new NoValueException(sprintf('Unable to set the value of `%s`', $camelizedFieldName));
}
return $object;
} | [
"public",
"static",
"function",
"setFieldValue",
"(",
"PageInterface",
"$",
"object",
",",
"$",
"fieldName",
",",
"$",
"value",
",",
"$",
"method",
"=",
"null",
")",
"{",
"$",
"setters",
"=",
"[",
"]",
";",
"// prefer method name given in the code option",
"if... | Set the variables to the given content type object.
@param PageInterface $object
@param $fieldName
@param $value
@param null $method
@return mixed
@throws \Sonata\AdminBundle\Exception\NoValueException | [
"Set",
"the",
"variables",
"to",
"the",
"given",
"content",
"type",
"object",
"."
] | 9c6e0f09de216e19795caac5840c197f46fde03d | https://github.com/networking/init-cms-bundle/blob/9c6e0f09de216e19795caac5840c197f46fde03d/src/Helper/PageHelper.php#L153-L178 | train |
networking/init-cms-bundle | src/Helper/PageHelper.php | PageHelper.makePageSnapshot | public function makePageSnapshot(PageInterface $page)
{
foreach ($page->getLayoutBlock() as $layoutBlock) {
$layoutBlockContent = $this->registry->getManagerForClass($layoutBlock->getClassType())->getRepository($layoutBlock->getClassType())->find(
$layoutBlock->getObjectId()
);
$layoutBlock->takeSnapshot($this->serializer->serialize($layoutBlockContent, 'json'));
}
$pageSnapshotClass = $this->pageSnapshotManager->getClassName();
/** @var \Networking\InitCmsBundle\Model\PageSnapshotInterface $pageSnapshot */
$pageSnapshot = new $pageSnapshotClass($page);
$pageSnapshot->setVersionedData($this->serializer->serialize($page, 'json'))
->setPage($page);
if ($oldPageSnapshot = $page->getSnapshot()) {
$snapshotContentRoute = $oldPageSnapshot->getContentRoute();
} else {
$contentRouteClass = $this->contentRouteManager->getClassName();
/** @var \Networking\InitCmsBundle\Model\ContentRouteInterface $snapshotContentRoute */
$snapshotContentRoute = new $contentRouteClass();
}
$pageSnapshot->setContentRoute($snapshotContentRoute);
$pageSnapshot->setPath(self::getPageRoutePath($page->getPath()));
$om = $this->registry->getManagerForClass($pageSnapshotClass);
$om->persist($pageSnapshot);
$om->flush();
$snapshotContentRoute->setPath(self::getPageRoutePath($page->getPath()));
$snapshotContentRoute->setObjectId($pageSnapshot->getId());
if ($oldPageSnapshot && ($oldPageSnapshot->getPath() != self::getPageRoutePath($page->getPath()))) {
$this->phpCache->clean();
}
$om = $this->registry->getManagerForClass(get_class($snapshotContentRoute));
$om->persist($snapshotContentRoute);
$om->flush();
} | php | public function makePageSnapshot(PageInterface $page)
{
foreach ($page->getLayoutBlock() as $layoutBlock) {
$layoutBlockContent = $this->registry->getManagerForClass($layoutBlock->getClassType())->getRepository($layoutBlock->getClassType())->find(
$layoutBlock->getObjectId()
);
$layoutBlock->takeSnapshot($this->serializer->serialize($layoutBlockContent, 'json'));
}
$pageSnapshotClass = $this->pageSnapshotManager->getClassName();
/** @var \Networking\InitCmsBundle\Model\PageSnapshotInterface $pageSnapshot */
$pageSnapshot = new $pageSnapshotClass($page);
$pageSnapshot->setVersionedData($this->serializer->serialize($page, 'json'))
->setPage($page);
if ($oldPageSnapshot = $page->getSnapshot()) {
$snapshotContentRoute = $oldPageSnapshot->getContentRoute();
} else {
$contentRouteClass = $this->contentRouteManager->getClassName();
/** @var \Networking\InitCmsBundle\Model\ContentRouteInterface $snapshotContentRoute */
$snapshotContentRoute = new $contentRouteClass();
}
$pageSnapshot->setContentRoute($snapshotContentRoute);
$pageSnapshot->setPath(self::getPageRoutePath($page->getPath()));
$om = $this->registry->getManagerForClass($pageSnapshotClass);
$om->persist($pageSnapshot);
$om->flush();
$snapshotContentRoute->setPath(self::getPageRoutePath($page->getPath()));
$snapshotContentRoute->setObjectId($pageSnapshot->getId());
if ($oldPageSnapshot && ($oldPageSnapshot->getPath() != self::getPageRoutePath($page->getPath()))) {
$this->phpCache->clean();
}
$om = $this->registry->getManagerForClass(get_class($snapshotContentRoute));
$om->persist($snapshotContentRoute);
$om->flush();
} | [
"public",
"function",
"makePageSnapshot",
"(",
"PageInterface",
"$",
"page",
")",
"{",
"foreach",
"(",
"$",
"page",
"->",
"getLayoutBlock",
"(",
")",
"as",
"$",
"layoutBlock",
")",
"{",
"$",
"layoutBlockContent",
"=",
"$",
"this",
"->",
"registry",
"->",
"... | Create a snapshot of a given page.
@param PageInterface $page | [
"Create",
"a",
"snapshot",
"of",
"a",
"given",
"page",
"."
] | 9c6e0f09de216e19795caac5840c197f46fde03d | https://github.com/networking/init-cms-bundle/blob/9c6e0f09de216e19795caac5840c197f46fde03d/src/Helper/PageHelper.php#L243-L284 | train |
networking/init-cms-bundle | src/Helper/PageHelper.php | PageHelper.unserializePageSnapshotData | public function unserializePageSnapshotData(PageSnapshotInterface $pageSnapshot, $unserializeTranslations = true)
{
$context = new PageSnapshotDeserializationContext();
$context->setDeserializeTranslations($unserializeTranslations);
return $this->serializer->deserialize($pageSnapshot->getVersionedData(), $pageSnapshot->getResourceName(), 'json', $context);
} | php | public function unserializePageSnapshotData(PageSnapshotInterface $pageSnapshot, $unserializeTranslations = true)
{
$context = new PageSnapshotDeserializationContext();
$context->setDeserializeTranslations($unserializeTranslations);
return $this->serializer->deserialize($pageSnapshot->getVersionedData(), $pageSnapshot->getResourceName(), 'json', $context);
} | [
"public",
"function",
"unserializePageSnapshotData",
"(",
"PageSnapshotInterface",
"$",
"pageSnapshot",
",",
"$",
"unserializeTranslations",
"=",
"true",
")",
"{",
"$",
"context",
"=",
"new",
"PageSnapshotDeserializationContext",
"(",
")",
";",
"$",
"context",
"->",
... | Unserialize the PageSnapshot data into a page object.
@param PageSnapshotInterface $pageSnapshot
@param bool $unserializeTranslations
@return array|\JMS\Serializer\scalar|object | [
"Unserialize",
"the",
"PageSnapshot",
"data",
"into",
"a",
"page",
"object",
"."
] | 9c6e0f09de216e19795caac5840c197f46fde03d | https://github.com/networking/init-cms-bundle/blob/9c6e0f09de216e19795caac5840c197f46fde03d/src/Helper/PageHelper.php#L294-L300 | train |
networking/init-cms-bundle | src/Helper/PageHelper.php | PageHelper.makeTranslationCopy | public function makeTranslationCopy(PageInterface $page, $locale)
{
$pageClass = $this->pageManager->getClassName();
/** @var PageInterface $pageCopy */
$pageCopy = new $pageClass();
$pageCopy->setPageName($page->getPageName());
$pageCopy->setMetaTitle($page->getMetaTitle());
$pageCopy->setUrl($page->getUrl());
$pageCopy->setMetaKeyword($page->getMetaKeyword());
$pageCopy->setMetaDescription($page->getMetaDescription());
$pageCopy->setActiveFrom($page->getActiveFrom());
$pageCopy->setIsHome($page->getIsHome());
$pageCopy->setLocale($locale);
$pageCopy->setTemplateName($page->getTemplateName());
$pageCopy->setOriginal($page);
$layoutBlocks = $page->getLayoutBlock();
$om = $this->registry->getManager();
foreach ($layoutBlocks as $layoutBlock) {
/** @var $newLayoutBlock \Networking\InitCmsBundle\Model\LayoutBlockInterface */
$newLayoutBlock = clone $layoutBlock;
$content = $om->getRepository($newLayoutBlock->getClassType())->find(
$newLayoutBlock->getObjectId()
);
$newContent = clone $content;
$om->persist($newContent);
$om->flush();
$newLayoutBlock->setObjectId($newContent->getId());
$newLayoutBlock->setPage($pageCopy);
$om->persist($newLayoutBlock);
}
$om->persist($pageCopy);
$om->flush();
return $pageCopy;
} | php | public function makeTranslationCopy(PageInterface $page, $locale)
{
$pageClass = $this->pageManager->getClassName();
/** @var PageInterface $pageCopy */
$pageCopy = new $pageClass();
$pageCopy->setPageName($page->getPageName());
$pageCopy->setMetaTitle($page->getMetaTitle());
$pageCopy->setUrl($page->getUrl());
$pageCopy->setMetaKeyword($page->getMetaKeyword());
$pageCopy->setMetaDescription($page->getMetaDescription());
$pageCopy->setActiveFrom($page->getActiveFrom());
$pageCopy->setIsHome($page->getIsHome());
$pageCopy->setLocale($locale);
$pageCopy->setTemplateName($page->getTemplateName());
$pageCopy->setOriginal($page);
$layoutBlocks = $page->getLayoutBlock();
$om = $this->registry->getManager();
foreach ($layoutBlocks as $layoutBlock) {
/** @var $newLayoutBlock \Networking\InitCmsBundle\Model\LayoutBlockInterface */
$newLayoutBlock = clone $layoutBlock;
$content = $om->getRepository($newLayoutBlock->getClassType())->find(
$newLayoutBlock->getObjectId()
);
$newContent = clone $content;
$om->persist($newContent);
$om->flush();
$newLayoutBlock->setObjectId($newContent->getId());
$newLayoutBlock->setPage($pageCopy);
$om->persist($newLayoutBlock);
}
$om->persist($pageCopy);
$om->flush();
return $pageCopy;
} | [
"public",
"function",
"makeTranslationCopy",
"(",
"PageInterface",
"$",
"page",
",",
"$",
"locale",
")",
"{",
"$",
"pageClass",
"=",
"$",
"this",
"->",
"pageManager",
"->",
"getClassName",
"(",
")",
";",
"/** @var PageInterface $pageCopy */",
"$",
"pageCopy",
"=... | create a copy of a given page object in a given locale.
@param PageInterface $page
@param $locale
@return PageInterface | [
"create",
"a",
"copy",
"of",
"a",
"given",
"page",
"object",
"in",
"a",
"given",
"locale",
"."
] | 9c6e0f09de216e19795caac5840c197f46fde03d | https://github.com/networking/init-cms-bundle/blob/9c6e0f09de216e19795caac5840c197f46fde03d/src/Helper/PageHelper.php#L310-L355 | train |
networking/init-cms-bundle | src/Helper/PageHelper.php | PageHelper.makePageCopy | public function makePageCopy(PageInterface $page)
{
$pageClass = $this->pageManager->getClassName();
/** @var PageInterface $pageCopy */
$pageCopy = new $pageClass();
$now = new \DateTime();
$postfix = sprintf(' copy %s', $now->format('d.m.Y H:i:s'));
$pageCopy->setPageName($page->getPageName().$postfix);
$pageCopy->setMetaTitle($page->getMetaTitle());
$pageCopy->setUrl($page->getUrl().$postfix);
$pageCopy->setMetaKeyword($page->getMetaKeyword());
$pageCopy->setMetaDescription($page->getMetaDescription());
$pageCopy->setActiveFrom($page->getActiveFrom());
$pageCopy->setIsHome(false);
$pageCopy->setTemplateName($page->getTemplateName());
$pageCopy->setLocale($page->getLocale());
$layoutBlocks = $page->getLayoutBlock();
$om = $this->registry->getManager();
foreach ($layoutBlocks as $layoutBlock) {
/** @var $newLayoutBlock \Networking\InitCmsBundle\Model\LayoutBlockInterface */
$newLayoutBlock = clone $layoutBlock;
$content = $om->getRepository($newLayoutBlock->getClassType())->find(
$newLayoutBlock->getObjectId()
);
$newContent = clone $content;
$om->persist($newContent);
$om->flush();
$newLayoutBlock->setObjectId($newContent->getId());
$newLayoutBlock->setPage($pageCopy);
$om->persist($newLayoutBlock);
}
$om->persist($pageCopy);
$om->flush();
return $pageCopy;
} | php | public function makePageCopy(PageInterface $page)
{
$pageClass = $this->pageManager->getClassName();
/** @var PageInterface $pageCopy */
$pageCopy = new $pageClass();
$now = new \DateTime();
$postfix = sprintf(' copy %s', $now->format('d.m.Y H:i:s'));
$pageCopy->setPageName($page->getPageName().$postfix);
$pageCopy->setMetaTitle($page->getMetaTitle());
$pageCopy->setUrl($page->getUrl().$postfix);
$pageCopy->setMetaKeyword($page->getMetaKeyword());
$pageCopy->setMetaDescription($page->getMetaDescription());
$pageCopy->setActiveFrom($page->getActiveFrom());
$pageCopy->setIsHome(false);
$pageCopy->setTemplateName($page->getTemplateName());
$pageCopy->setLocale($page->getLocale());
$layoutBlocks = $page->getLayoutBlock();
$om = $this->registry->getManager();
foreach ($layoutBlocks as $layoutBlock) {
/** @var $newLayoutBlock \Networking\InitCmsBundle\Model\LayoutBlockInterface */
$newLayoutBlock = clone $layoutBlock;
$content = $om->getRepository($newLayoutBlock->getClassType())->find(
$newLayoutBlock->getObjectId()
);
$newContent = clone $content;
$om->persist($newContent);
$om->flush();
$newLayoutBlock->setObjectId($newContent->getId());
$newLayoutBlock->setPage($pageCopy);
$om->persist($newLayoutBlock);
}
$om->persist($pageCopy);
$om->flush();
return $pageCopy;
} | [
"public",
"function",
"makePageCopy",
"(",
"PageInterface",
"$",
"page",
")",
"{",
"$",
"pageClass",
"=",
"$",
"this",
"->",
"pageManager",
"->",
"getClassName",
"(",
")",
";",
"/** @var PageInterface $pageCopy */",
"$",
"pageCopy",
"=",
"new",
"$",
"pageClass",... | create a copy of a given page object.
@param PageInterface $page
@return PageInterface | [
"create",
"a",
"copy",
"of",
"a",
"given",
"page",
"object",
"."
] | 9c6e0f09de216e19795caac5840c197f46fde03d | https://github.com/networking/init-cms-bundle/blob/9c6e0f09de216e19795caac5840c197f46fde03d/src/Helper/PageHelper.php#L364-L413 | train |
networking/init-cms-bundle | src/Helper/PageHelper.php | PageHelper.matchContentRouteRequest | public function matchContentRouteRequest(Request $request)
{
$requestParams = $this->router->matchRequest($request);
if (is_array($requestParams) && !empty($requestParams)) {
$request->attributes->add($requestParams);
unset($requestParams['_route']);
unset($requestParams['_controller']);
$request->attributes->set('_route_params', $requestParams);
$configuration = $request->attributes->get('_template');
$request->attributes->set('_template', $configuration->getTemplate());
$request->attributes->set('_template_vars', $configuration->getVars());
$request->attributes->set('_template_streamable', $configuration->isStreamable());
}
return $request;
} | php | public function matchContentRouteRequest(Request $request)
{
$requestParams = $this->router->matchRequest($request);
if (is_array($requestParams) && !empty($requestParams)) {
$request->attributes->add($requestParams);
unset($requestParams['_route']);
unset($requestParams['_controller']);
$request->attributes->set('_route_params', $requestParams);
$configuration = $request->attributes->get('_template');
$request->attributes->set('_template', $configuration->getTemplate());
$request->attributes->set('_template_vars', $configuration->getVars());
$request->attributes->set('_template_streamable', $configuration->isStreamable());
}
return $request;
} | [
"public",
"function",
"matchContentRouteRequest",
"(",
"Request",
"$",
"request",
")",
"{",
"$",
"requestParams",
"=",
"$",
"this",
"->",
"router",
"->",
"matchRequest",
"(",
"$",
"request",
")",
";",
"if",
"(",
"is_array",
"(",
"$",
"requestParams",
")",
... | Fills the request object with the content route parameters if found.
@param Request $request
@return Request | [
"Fills",
"the",
"request",
"object",
"with",
"the",
"content",
"route",
"parameters",
"if",
"found",
"."
] | 9c6e0f09de216e19795caac5840c197f46fde03d | https://github.com/networking/init-cms-bundle/blob/9c6e0f09de216e19795caac5840c197f46fde03d/src/Helper/PageHelper.php#L422-L440 | train |
networking/init-cms-bundle | src/Helper/PageHelper.php | PageHelper.jsonPageIsActive | public function jsonPageIsActive($jsonString)
{
$page = json_decode($jsonString, true);
$now = new \DateTime();
$activeStart = array_key_exists('active_from', $page) ? new \DateTime($page['active_from']) : new \DateTime();
$activeEnd = array_key_exists('active_to', $page) ? new \DateTime($page['active_to']) : new \DateTime();
if ($now->getTimestamp() >= $activeStart->getTimestamp() &&
$now->getTimestamp() <= $activeEnd->getTimestamp()
) {
return $page['status'] == PageInterface::STATUS_PUBLISHED;
}
return false;
} | php | public function jsonPageIsActive($jsonString)
{
$page = json_decode($jsonString, true);
$now = new \DateTime();
$activeStart = array_key_exists('active_from', $page) ? new \DateTime($page['active_from']) : new \DateTime();
$activeEnd = array_key_exists('active_to', $page) ? new \DateTime($page['active_to']) : new \DateTime();
if ($now->getTimestamp() >= $activeStart->getTimestamp() &&
$now->getTimestamp() <= $activeEnd->getTimestamp()
) {
return $page['status'] == PageInterface::STATUS_PUBLISHED;
}
return false;
} | [
"public",
"function",
"jsonPageIsActive",
"(",
"$",
"jsonString",
")",
"{",
"$",
"page",
"=",
"json_decode",
"(",
"$",
"jsonString",
",",
"true",
")",
";",
"$",
"now",
"=",
"new",
"\\",
"DateTime",
"(",
")",
";",
"$",
"activeStart",
"=",
"array_key_exist... | Returns if a page is active or inactive based on json string from page snapshot.
@param $jsonString
@return bool | [
"Returns",
"if",
"a",
"page",
"is",
"active",
"or",
"inactive",
"based",
"on",
"json",
"string",
"from",
"page",
"snapshot",
"."
] | 9c6e0f09de216e19795caac5840c197f46fde03d | https://github.com/networking/init-cms-bundle/blob/9c6e0f09de216e19795caac5840c197f46fde03d/src/Helper/PageHelper.php#L449-L465 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.