Commit 20ec8968 authored by Emiliano Balbuena's avatar Emiliano Balbuena

(cs): fixer

1 merge request!308WIP: (feat): Minds Pro
Pipeline #81167708 failed with stages
in 11 minutes
......@@ -84,7 +84,7 @@ class SEO
$serverParams = $request->getServerParams() ?? [];
$host = parse_url($serverParams['HTTP_ORIGIN'] ?? '', PHP_URL_HOST) ?: $serverParams['HTTP_HOST'];
$proSettings = $proDomain->lookup($host);
$proSettings = $proDomain->lookup($host);
if ($proSettings && (count($slugs) < 2 || $slugs[0] === 'blog')) {
$slugParts = explode('-', $slugs[1]);
......
......@@ -66,14 +66,15 @@ class SEO
'og:image' => $this->user->getIconURL('large'),
]);
Manager::add('/', function() {});
Manager::add('/', function () {
});
Manager::add('/newsfeed', [$this, 'activityHandler']);
Manager::add('/media', [$this, 'entityHandler']);
// blog route added in Blogs\SEO
}
function activityHandler($slugs = [])
public function activityHandler($slugs = [])
{
if (isset($slugs[0]) && is_numeric($slugs[0])) {
$activity = new Activity($slugs[0]);
......@@ -116,20 +117,20 @@ class SEO
}
}
function getEntityProperty($entity, $prop)
public function getEntityProperty($entity, $prop)
{
$getter = "get${$prop}";
if (isset($entity->{$prop})) {
return $entity->{$prop};
} else if (Helpers\MagicAttributes::getterExists($entity, $getter)) {
} elseif (Helpers\MagicAttributes::getterExists($entity, $getter)) {
return $entity->{$getter}();
}
return null;
}
function entityHandler($slugs = [])
public function entityHandler($slugs = [])
{
if (isset($slugs[0]) && is_numeric($slugs[0])) {
$entity = $this->entitiesBuilder->single($slugs[0]);
......
......@@ -103,7 +103,8 @@ class Settings implements JsonSerializable
/** @var array */
protected $featuredContent = [];
public function getOneLineHeadline() {
public function getOneLineHeadline()
{
return preg_replace("/\\r?\\n+/", ' ', $this->headline);
}
......
......@@ -21,8 +21,7 @@ class Manager
*/
public function __construct(
$middleware = null
)
{
) {
$this->middleware = $middleware ?: [
new Middleware\SEOMiddleware(),
new Middleware\ProMiddleware(), // this needs to always be the last element in this array
......
......@@ -40,8 +40,7 @@ class ProMiddleware implements RouterMiddleware
$manager = null,
$seo = null,
$entitiesBuilder = null
)
{
) {
$this->domain = $domain ?: Di::_()->get('Pro\Domain');
$this->manager = $manager ?: Di::_()->get('Pro\Manager');
$this->seo = $seo ?: Di::_()->get('Pro\SEO');
......
......@@ -13,5 +13,4 @@ class SEOMiddleware implements RouterMiddleware
{
new SEO\Defaults(Di::_()->get('Config'));
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment