Deprecated Code Reference (ongoing)

Deprecated Code Reference (ongoing)

This doc holds a reference list of commonly used code that is deprecated, and their replacements. These functions may still work and exist now, but can be removed from future versions of concrete5 and thus cause problems in the future.

This is a work in progress. This list will change as new functions are found and new versions are released.

Note:

In the replacements you will sometimes find references to $app. You can access the application in some controllers with $this->app, or if it’s not available, retrieve it with:

$app = \Concrete\Core\Support\Facade\Application::getFacadeApplication();

Using $app may result in faster code.

Loader functions

Loader::db() - deprecated since 5.7

replacements:

$db = Database::connection();

$db = $app->make('database')->connection(); /* @var $db \Concrete\Core\Database\Connection\Connection */

Loader::helper() - deprecated since 5.7

replacements:

$pkgh = Core::make('/packages/' . $pkgHandle . '/helper/' . $service);

$h = Core::make('helper/' . $service);

examples:

$th = Core::make('helper/text');

$nh = Core::make('helper/navigation');

$ps = Core::make('helper/form/page_selector');

$al = Core::make('helper/concrete/asset_library');

$color = Core::make('helper/form/color');

$form = Loader::helper(‘form’) - deprecated since 5.7

replacement:

block/view.php: $form is already defined

Loader::packageElement() - deprecated since 5.7

replacement:

$ve = View::element($file, $args, $_pkgHandle);

Loader::element() - deprecated since 5.7

replacement:

$ve = View::element($file, $args, $_pkgHandle);

Loader::model() - deprecated since 5.7

*replacement: *none

Loader::library() - deprecated since 5.7

*replacement: *none

Loader::controller() - deprecated since 5.7

replacement:

in a page: Page::getPageController();

BlockType

BlockType::installBlockTypeFromPackage() - deprecated since 5.7

replacement:

$bt = BlockType::installBlockType($handle, $pkg);

Database

Database::get() - deprecated since 5.7

replacement:

$db = Database::connection();

$db = $app->make('database')->connection(); /* @var $db \Concrete\Core\Database\Connection\Connection */

$db->execute() - deprecated since 5.7

replacement(s):

$db->executeQuery($q, array($arguments));

($q instanceOf \Doctrine\DBAL\Statement): $q->execute($arguments);

$db->GetOne() - deprecated since 5.7

replacement:

$res = $db->fetchColumn($q, array($arguments))

$db->GetAll() - deprecated since 5.7

replacement:

$res = $db->fetchAll($q, array($arguments))

File

$f->isError() - deprecated since 5.7

returns false

replacement: none, (File::getByID() != null)

Controller

PageController::isPost() - deprecated since 5.7

replacement:

$this->request->getMethod() == 'POST'

PageController::post() - deprecated since 5.7

replacement:

$this->request->request->get()

PageController::get() - deprecated since 5.7 (for HTTP GET parameters)

replacement:

$this->request->query->get()

PageController::get() can still be used to fetch the variables that have been made available through PageController::set(). In case you are fetching HTTP request parameters, you should be using the above method insteead.

Permissions

FilePermissions::getGlobal() - deprecated since 5.7

replacement:

$fp = new Permissions(FileSet::getGlobal());

TaskPermission() - deprecated since 5.7

replacement:

$tp = new Permissions();

Request

Request::getInstance()

replacement:

$r = $app->make(\Concrete\Core\Http\Request::class);

UserInfo

UserInfo::getByID()

replacement:

$ui = $app->make(\Concrete\Core\User\UserInfoFactory::class)->getByID();

Loading Conversation