Trying to add social media links to Drupal website - drupal

I'm trying to add social media icons to my drupal website and followed this guide to try and install them. The module seems to install fine, however when I try to configure it to add different links on clicking save it brings me to a webpage that simply says The website encountered an unexpected error. Please try again later.
I've tried uninstalling/reinstalling the plugin and that didn't seem to do anything. Are there some permissions I'm missing in my set up? I'm pretty much brand new to drupal
Edit: The url of the error is admin/structure/block/manage/socialmedialinks?destination=/node
and some of the error log:
TypeError: Argument 2 passed to Egulias\EmailValidator\EmailValidator::isValid() must implement interface Egulias\EmailValidator\Validation\EmailValidation, bool given,

It seems the social_media_links drupal module version 8.x-2.6 has a bug when it checks the validity of email addresses.
There is an issue in the module's issue queue for it HERE.
There is a patch attached to the issue (attached below):
diff --git a/src/Plugin/SocialMediaLinks/Platform/Email.php b/src/Plugin/SocialMediaLinks/Platform/Email.php
index 007e59f..2926d47 100755
--- a/src/Plugin/SocialMediaLinks/Platform/Email.php
+++ b/src/Plugin/SocialMediaLinks/Platform/Email.php
## -4,7 +4,6 ## namespace Drupal\social_media_links\Plugin\SocialMediaLinks\Platform;
use Drupal\social_media_links\PlatformBase;
use Drupal\Core\Form\FormStateInterface;
-use Egulias\EmailValidator\EmailValidator;
use Drupal\Core\Url;
/**
## -29,9 +28,9 ## class Email extends PlatformBase {
*/
public static function validateValue(array &$element, FormStateInterface $form_state, array $form) {
if (!empty($element['#value'])) {
- $validator = new EmailValidator();
+ $validator = \Drupal::service('email.validator');
- if (!$validator->isValid($element['#value'], TRUE)) {
+ if (!$validator->isValid($element['#value'])) {
$form_state->setError($element, t('The entered email address is not valid.'));
}
}

Related

phpunit testable livewire fails with Undefined array key "fingerprint"

When trying a test that came with Laravel and Jetstream/Livewire libraries, I get an undefined array key "fingerprint" error message
Undefined array key "fingerprint"
at vendor/livewire/livewire/src/Testing/TestableLivewire.php:181
public function pretendWereSendingAComponentUpdateRequest($message, $payload)
{
$result = $this->callEndpoint('POST', '/livewire/message/'.$this->componentName, [
'fingerprint' => $this->payload['fingerprint'],
'serverMemo' => $this->payload['serverMemo'],
'updates' => [['type' => $message, 'payload' => $payload]],
]);
This happens for any out of the box feature tests that ship with Laravel9 with Jetstream when used against my project.
Here is one example that fails at the Livewire::test.... line.
The user is created and authenticating without issue and confirmed in other phpunit tests.
class BrowserSessionsTest extends TestCase
{
use RefreshDatabase;
public function test_other_browser_sessions_can_be_logged_out(): void
{
$this->actingAs($user = User::factory()->create());
Livewire::test(LogoutOtherBrowserSessionsForm::class)
->set('password', $user->password)
->call('logoutOtherBrowserSessions')
->assertSuccessful();
}
}
I stood up a fresh Laravel 9 project which works and began inserting various areas from my project into the fresh project as a way of hopefully identifying the issue. Session parameters, events, migrations, factories, models, were not the issue as it continued to work in the fresh project.
One thing I noticed is that the generic routes are not accepted in my project within he test cases. I have to insert 'https://realtor.host' in front of every test route (e.g. $response = $this->get('https://realtor.host/register');
I was curious if it was not evaluating the livewire route and I tried to add my domain into the vendor's livewire component in which the test still failed and that did not cause it to work.
Any ideas on where else I can look?

Zend\Permissions\Rbac\Role Error 500 when try to instantiate object

I'm trying to implement a RBAC in my project, but I can't instantiate Rbac class.
My code:
<?php
namespace Login\Controller;
use Zend\Mvc\Controller\AbstractActionController;
use Zend\Permissions\Rbac\Rbac;
use Zend\Permissions\Rbac\Role;
class TesteController extends AbstractActionController {
public function indexAction() {
$role = new Role('teste');
die('=== FIM ===');
}
}
When I comment the Role line it shows "=== FIM ===", but when it isn't commented it gives 500 error.
I already check the module struct in vendor and it's alright.
Do I need to do anything else when I install a vendor module via composer to zend 3 recognize it?
The error was cause by my php version that doesn't accept return type declarations. The Rbac module is full of it.

Laravel 5.3 Redefine "reset email" blade template

How to customize the path of the reset email blade template in Laravel 5.3?
The template used is: vendor/laravel/framework/src/Illuminate/Notifications/resources/views/email.blade.php
I'd like to build my own.
Also, how to change the text of this email predefined in: vendor/laravel/framework/src/Illuminate/Auth/Notifications/ResetPassword.php
public function toMail()
{
return (new MailMessage)
->line([
'You are receiving this email because we received a password reset request for your account.',
'Click the button below to reset your password:',
])
->action('Reset Password', url('password/reset', $this->token))
->line('If you did not request a password reset, no further action is required.');
}
To change template you should use artisan command php artisan vendor:publish it will create blade templates in your resources/views/vendor directory. To change text of email you should override the sendPasswordResetNotification method on your User model. This is described here https://laravel.com/docs/5.3/passwords in Reset Email Customization section.
You must add new method to your User model.
public function sendPasswordResetNotification($token)
{
$this->notify(new ResetPasswordNotification($token));
}
and use your own class for notification instead ResetPasswordNotification.
UPDATED: for #lewis4u request
Step by step instruction:
To create a new Notification class, you must use this command line php artisan make:notification MyResetPassword . It will make a new Notification Class 'MyResetPassword' at app/Notifications directory.
add use App\Notifications\MyResetPassword; to your User model
add new method to your User model.
public function sendPasswordResetNotification($token)
{
$this->notify(new MyResetPassword($token));
}
run php artisan command php artisan vendor:publish --tag=laravel-notifications After running this command, the mail notification templates will be located in the resources/views/vendor/notifications directory.
Edit your MyResetPassword class method toMail() if you want to. It's described here https://laravel.com/docs/5.3/notifications
Edit your email blade template if you want to. It's resources/views/vendor/notifications/email.blade.php
Bonus: Laracast video: https://laracasts.com/series/whats-new-in-laravel-5-3/episodes/9
PS: Thanks #Garric15 for suggestion about php artisan make:notification
I wanted to elaborate on a very helpful Eugen’s answer, but didn’t have enough reputation to leave a comment.
In case you like to have your own directory structure, you don’t have to use Blade templates published to views/vendor/notifications/... When you create a new Notification class and start building your MailMessage class, it has a view() method that you can use to override default views:
/**
* Get the mail representation of the notification.
*
* #param mixed $notifiable
* #return \Illuminate\Notifications\Messages\MailMessage
*/
public function toMail($notifiable)
{
return (new MailMessage)
->view('emails.password_reset');
// resources/views/emails/password_reset.blade.php will be used instead.
}
In Addition to the above answer for Laravel 5.6, here it is easier to pass variables in an array to your custom email template.
/**
* Get the mail representation of the notification.
*
* #param mixed $notifiable
* #return \Illuminate\Notifications\Messages\MailMessage
*/
public function toMail($notifiable)
{
$url = url('/invoice/'.$this->invoice->id);
return (new MailMessage)
->subject('Invoice Paid')
->markdown('emails.password_reset', ['url' => $url]);
}
https://laravel.com/docs/5.6/notifications

How to use Facebook PHP SDK with Zend Framework 2

I want to be able to use the Facebook PHP SDK with the new ZEND Framework 2 platform. How to do it?
Zend Framework 2 is quite different as previous version ZF1.
When I try the standard PHP in the main application controller IndexController':
require_once("facebook.php");
class IndexController extends AbstractActionController
{
public $facebook;
public function __construct() {
$this->facebook = new Facebook(array(
'appId' => 'appId',
'secret' => 'secret_key'
));
}
/*
...
*/
}
I get following error: Fatal error: Cannot redeclare class Facebook in /../module/Application/src/Application/Controller/Facebook.php on line 160
According to that error message the problem is that you now have two classes called Facebook in that namespace. Try ensuring you only have one class called Facebook.
I had the same problem when I needed to include the Facebook SDK in a ZF2 application.
You don't need to use any additional modules for FB SDK integration. The trick is to include the facebook library with ClassMapAutoloader, e.g.:
array(
'Facebook' => 'vendor/FB/facebook.php',
)
Detailed instructions are here
I can't help you specifically on the difference between ZF1 & ZF2 but a simple search in google gave me this result, I think because ZF autoloads classes and you tried to require it again they are in conflict.

Is is possible to have symfony2 log missing translation strings so that I know what needs adding to my xilff files?

I have a symfony project in which I've been through my twig templates and added {% trans %}...{% endtrans %} or adding translations like {{ title|trans }} where appropriate. I've also added a messages.de.xliff file and that is working perfectly for the few translations I have tried.
Is there a way I can get a list of strings missing from my xliff file? It's quite hard to keep track of every translation as I add it. It seems like it should log a failure to get a translation in a log file somewhere, but I've been googling a while and can't find anything.
Hi Try following May Be helpful.
https://github.com/schmittjoh/JMSTranslationBundle/blob/master/Resources/doc/index.rst
Very powerful tool and definitely takes care of you problem.
This is a very crappy patch to apply in vendor/symfony that does what I need. Probably not to be run on a production server!
diff --git a/src/Symfony/Component/Translation/MessageCatalogue.php b/src/Symfony/Component/Translation/MessageCatalogue.php
index b55676f..98a5cba 100644
--- a/src/Symfony/Component/Translation/MessageCatalogue.php
+++ b/src/Symfony/Component/Translation/MessageCatalogue.php
## -128,6 +128,8 ## class MessageCatalogue implements MessageCatalogueInterface
return $this->fallbackCatalogue->get($id, $domain);
}
+ error_log('Translation not found: "' . $id . '"');
+
return $id;
}
My solution was to overwrite the Translator and MessageCatalogue classes.
Translator:
class RegisteringTranslator extends \Symfony\Component\Translation\Translator
{
protected function loadCatalogue($locale)
{
parent::loadCatalogue($locale);
if ( ! $this->catalogues[$locale] instanceof RegisteringMessageCatalogue) {
$registeringCatalogue = new RegisteringMessageCatalogue($locale);
$registeringCatalogue->addCatalogue($this->catalogues[$locale]);
$this->catalogues[$locale] = $registeringCatalogue;
}
}
}
Catalogue:
class RegisteringMessageCatalogue extends \Symfony\Component\Translation\MessageCatalogue
{
public function get($id, $domain = 'messages')
{
if ( ! $this->has($id, $domain)) {
error_log('Translation not found: "' . $id . '"');
}
return parent::get($id, $domain);
}
}
Of course you need to use the new Translator class.
Also not very nice because it uses the protected methods and properties of Translator class. But better than changing the Symfony code directly.
I know this is an old question, but I'm posting here just in case somebody still has the same problem.
Starting from Symfony 2.6, you'll find a very nice addition to the web debug toolbar that shows how many translations you're missing.
By clicking it, the profiler will display a detailed list of missing translation.
Works out of the box, without any configuration.
Normally you should be able to use the Symfony command debug:translation via app/console.
Something like this:
$ php app/console debug:translation --only-missing <locale> <Bundle Name>
A concrete example would be:
$ php app/console debug:translation --only-missing nl AppBundle
That would output:
----------- ---------- ------------------------------------------------------------------------------------------------------- ------------------------------------------
State Domain Id Message Preview (nl)
----------- ---------- ------------------------------------------------------------------------------------------------------- ------------------------------------------
missing messages Create a clean selection Create a clean selection
missing messages New Selection New Selection
missing messages login.labels.geoserver_url login.labels.geoserver_url

Resources