class ContentManager extends BaseManager

Core content manager

Methods

object
save(object $obj)

Save handler, because DRY

Paginator
getPaginator(integer $page = 1, integer $limit = 50)

Helps paginate models using the query bulder. Bit more complicated than the native array method, but works better for larger data sets

boolean
restDelete(number $id)

Delete an object with rest

restCreate(array $data)

Create a new object

restUpdate(int $id, array $data)

Update an existing object

mixed
find(mixed $parameters = null)

Find content

mixed
findFirst(mixed $params = null)

Find first based on params

mixed
findFirstById(mixed $params = null)

Find first content by ID

findById($params = null)

No description

object
findFirstByUrl(mixed $url)

Find first content item by given URL.

object
findFirstByUuid(string $uuid)

Find first item by given UUID

findFirstBySrn(string $srn)

Find first instance by SRN

findRelatedByKeywords($keywords = array(), $minRank = 1.0)

No description

findRelatedByContent($content)

No description

getUrlSlug($content)

No description

object
create($input, $user = false, $nopush = false)

Create content with given properties.

object
update($id, $input, $user = false, $nopush = false)

Update content object.

delete(int $id)

Delete content item

attach(integer $id, array $file, array $iptcData = array())

Attach a file to a content item File is an array containing: * file - BASE64 encoded file content * name - original file name

editAttachment($id, $input, $user)

No description

importFromJSON($json, $importOriginals = false)

No description

Details

in BaseManager at line line 23
object save(object $obj)

Save handler, because DRY

Parameters

object $obj Model to be saved

Return Value

object Model

Exceptions

Exception Json encoded string of validation errors

in BaseManager at line line 60
Paginator getPaginator(integer $page = 1, integer $limit = 50)

Helps paginate models using the query bulder. Bit more complicated than the native array method, but works better for larger data sets

Because it's based on Phalcon's QueryBuilder, it supports a fluent filtering interface:

    $manager = $this->foo_manager;
    $items = $manager->getPaginator(1, 20)
        ->orderBy('created_at desc')
        ->where('name = :name:', array('name' => $name))
        ->andWhere('type = :type:', array('type' => $type))
        ->paginate();

    echo json_encode($items);

Parameters

integer $page Current page
integer $limit Per page limit

Return Value

Paginator

in BaseManager at line line 80
boolean restDelete(number $id)

Delete an object with rest

Parameters

number $id

Return Value

boolean

Exceptions

Exception

in BaseManager at line line 103
restCreate(array $data)

Create a new object

Parameters

array $data

in BaseManager at line line 117
restUpdate(int $id, array $data)

Update an existing object

Parameters

int $id
array $data

at line line 30
mixed find(mixed $parameters = null)

Find content

Parameters

mixed $parameters

Return Value

mixed

at line line 40
mixed findFirst(mixed $params = null)

Find first based on params

Parameters

mixed $params

Return Value

mixed

at line line 50
mixed findFirstById(mixed $params = null)

Find first content by ID

Parameters

mixed $params

Return Value

mixed

at line line 55
findById($params = null)

Parameters

$params

at line line 76
object findFirstByUrl(mixed $url)

Find first content item by given URL.

URL can either be a full URL slug or URL object. For example both of the following are valid:

    $content = ContentManager::findFirstByUrl('some/path');

    $url = UrlModel::findFirstBySlug('another/path');
    $content = ContentManager::findFirstByUrl($url);

Parameters

mixed $url URL

Return Value

object Content item

at line line 104
object findFirstByUuid(string $uuid)

Find first item by given UUID

Parameters

string $uuid

Return Value

object ContentModel

at line line 114
Content findFirstBySrn(string $srn)

Find first instance by SRN

Parameters

string $srn SRN

Return Value

Content

at line line 124
findRelatedByKeywords($keywords = array(), $minRank = 1.0)

Parameters

$keywords
$minRank

at line line 128
findRelatedByContent($content)

Parameters

$content

at line line 172
getUrlSlug($content)

Parameters

$content

at line line 234
object create($input, $user = false, $nopush = false)

Create content with given properties.

  • slug
  • version
  • abstract
  • content
  • state
  • urls
  • attachment

URLS can be provided either as a single string, or an array with: * url * is_default

For example:

$data = [
    'slug' => 'fronch-toast'.uniqid(),
    'urls' => [
        'a-test-url'.uniqid(),
        [
            'url' => 'another test url'.uniqid(),
            'is_default' => 1
        ]
    ]
];

Attachment is an array containing: * file - BASE64 encoded file data * name - original file name

Parameters

$input
$user
$nopush

Return Value

object ContentModel

at line line 566
object update($id, $input, $user = false, $nopush = false)

Update content object.

Accepts the same properties as create, including Urls. Keep in mind that Url associations are permanent. You may only append new Urls, existing Urls will always be maintained.

Will also create a new version containing all of the current data, before save.

Additionally, sending an attachment will remove the original attachment and replace with the new file.

Parameters

$id
$input
$user
$nopush

Return Value

object ContentModel

at line line 931
delete(int $id)

Delete content item

Parameters

int $id ID

Exceptions

Exception

at line line 963
Attachment attach(integer $id, array $file, array $iptcData = array())

Attach a file to a content item File is an array containing: * file - BASE64 encoded file content * name - original file name

Parameters

integer $id Parent content id
array $file File data
array $iptcData IPTC data will populate this array if type is image

Return Value

Attachment

at line line 1064
editAttachment($id, $input, $user)

Parameters

$id
$input
$user

at line line 1189
importFromJSON($json, $importOriginals = false)

Parameters

$json
$importOriginals