Skip to content

Instantly share code, notes, and snippets.

View redleafar's full-sized avatar
🎯
Focusing

Rafael Bermúdez redleafar

🎯
Focusing
  • Globant
  • Bogotá, Colombia
View GitHub Profile
@redleafar
redleafar / breadcrumb.md
Last active September 4, 2016 09:48
Set breadcrumb in sonata admin
public function __toString() {
		return $this->getTitle() ? (string)$this->getTitle() : '';
}
@redleafar
redleafar / Extend.md
Last active September 4, 2016 21:00
Extend templates from vendor bundles

Extend templates from vendor bundles

For extend or replace templates (or another types of resource files) you just have to create a folder in app/Resources with the name of the bundle, from which you want to extend the template, and put the new file inside a folder called ‘view’ following the same structure that it has in the vendor. For example for login.html.twig located in vendor/Sonata-project/user-bundle/resources/views/security/login.html.twig, you have to put it in app/Resources/SonataUserBundle/security/login.html.twig

@redleafar
redleafar / 0_current_ancestor_error.twig
Last active September 4, 2016 09:35
Error: Method “currentAncestor” for object “Knp\Menu\MenuItem” does not exist in Sonata
{# app/resources/SonataBlockBundle/views/Block/ block_side_menu_template.html.twig #}
{# Fixed changing this : #}
{%- if item.current %}
{%- set classes = classes|merge([options.currentClass]) %}
{%- elseif item.currentAncestor %}
{%- set classes = classes|merge([options.ancestorClass]) %}
{%- endif %}
@redleafar
redleafar / publickey-git-error.markdown
Created September 4, 2016 20:59 — forked from adamjohnson/publickey-git-error.markdown
Fix "Permission denied (publickey)" error when pushing with Git

"Help, I keep getting a 'Permission Denied (publickey)' error when I push!"

This means, on your local machine, you haven't made any SSH keys. Not to worry. Here's how to fix:

  1. Open git bash (Use the Windows search. To find it, type "git bash") or the Mac Terminal. Pro Tip: You can use any *nix based command prompt (but not the default Windows Command Prompt!)
  2. Type cd ~/.ssh. This will take you to the root directory for Git (Likely C:\Users\[YOUR-USER-NAME]\.ssh\ on Windows)
  3. Within the .ssh folder, there should be these two files: id_rsa and id_rsa.pub. These are the files that tell your computer how to communicate with GitHub, BitBucket, or any other Git based service. Type ls to see a directory listing. If those two files don't show up, proceed to the next step. NOTE: Your SSH keys must be named id_rsa and id_rsa.pub in order for Git, GitHub, and BitBucket to recognize them by default.
  4. To create the SSH keys, type ssh-keygen -t rsa -C "your_email@example.com". Th
@redleafar
redleafar / new_gist_file.md
Last active September 6, 2016 17:20
Let Sonata admin users only edit entities they own

Let Sonata admin users only edit entities they own

First configure ACL permissions correctly:

https://sonata-project.org/bundles/admin/master/doc/reference/security.html

Remember these 3 things explained in the link:

  1. Install the ACL tables: php app/console init:acl
  2. If you have Admin classes, you can install or update the related CRUD ACL rules (I HAD PROBLEMS NOT EXECUTING THIS ONE, REMEMBER TO RUN IT):
@redleafar
redleafar / date_time_picker.md
Created September 5, 2016 16:49
DateTime picker in sonata admin

DateTime picker in sonata admin forms

->add('fecha', 'sonata_type_datetime_picker', array('label' => 'Fecha',  'format'=> 'dd/MM/yyyy hh:mm',
                    'dp_side_by_side'       => true,
                    'dp_use_current'        => false,
                    'dp_use_seconds'        => false,))
@redleafar
redleafar / upload_image_from_android.md
Last active September 6, 2016 17:19
Upload Image from Android app to Symfony server
@redleafar
redleafar / remove_actionbar_shadow.md
Last active September 8, 2016 03:50
Remove action bar shadow

Add app:elevation="0dp" to appbarlayout as shown below:

<android.support.design.widget.AppBarLayout
    android:layout_width="match_parent"
    android:layout_height="?attr/actionBarSize"
    android:theme="@style/AppTheme.AppBarOverlay"
    app:elevation="0dp">

 
@redleafar
redleafar / font_side_menu.md
Last active February 28, 2021 22:09
How to set font of side menu (navigation view) items

Set font of side menu items

Create this class:

import android.graphics.Paint;
import android.graphics.Typeface;
import android.text.TextPaint;
import android.text.style.TypefaceSpan;
@redleafar
redleafar / image_navigatorview.md
Created September 8, 2016 04:32
How to set a background image in navigator view

Just add: android:background="@drawable/image" (in this case fondo_menu):

<android.support.design.widget.NavigationView
        android:id="@+id/nav_view"
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:layout_gravity="start"
        android:fitsSystemWindows="true"
 android:background="@drawable/fondo_menu"