friggeri_cv-1.0.0-alpha2/friggeri_cv.install
friggeri_cv.install
<?php
/**
* @file
* Install, update and uninstall functions for the Friggeri CV module.
*/
use Drupal\friggeri_cv\ProfileDefault;
use Drupal\Core\Link;
use Drupal\Core\Url;
use Symfony\Component\HttpFoundation\RedirectResponse;
/**
* Implements hook_install().
*/
function friggeri_cv_install() {
$profile = ProfileDefault::generate();
$link = Link::createFromRoute(
"profile",
"entity.profile.edit_form",
['profile' => $profile->id()],
['absolute' => TRUE]
);
\Drupal::messenger()->addStatus(
t('A default @profile has been generated upon the installation',
['@profile' => $link->toString()]
)
);
$url = Url::fromRoute("entity.profile.collection")->setAbsolute()->toString();
$response = new RedirectResponse($url);
$response->send();
}
